Giter Club home page Giter Club logo

codingforentrepreneurs / try-django-19 Goto Github PK

View Code? Open in Web Editor NEW
279.0 54.0 165.0 4.59 MB

Try Django 1.9 is an introduction to Django version 1.9 by creating a simple, yet robust, Django blog. This series covers a variety of Django basics as well as Django 1.9 specific material. Created by Team CFE @ http://joincfe.com.

Home Page: https://www.codingforentrepreneurs.com/projects/try-django-19/

License: MIT License

Python 11.48% CSS 28.92% HTML 3.42% JavaScript 56.18%
django django-blog tutorial team-cfe python

try-django-19's Introduction

Try Django 1.9 Logo

Try Django 1.9

Try Django 1.9 is an introduction to Django version 1.9 by creating a simple, yet robust, Django blog. This series covers a variety of Django basics as well as Django 1.9 specific material. Created by Team CFE @ http://joincfe.com.

The tutorial videos are available on our YouTube channel and ad-free on Coding for Entrepreneurs.

Subscribe to our YouTube Channel

Thanks for watching!

Team CFE

Lecture Code

The tutorial code below is the final code from the end of each tutorial video. Each link below is tied directly to the tutorial's title. Please note that some videos will not have code reference code.

4 - Versions & Install

5 - Superuser & Admin

6 - First App & Model

7 - Model to Admin

8 - Customize Admin

9 - CRUD

10 - Writing our first View

12 - Mapping URLs to Views

13 - In App URLs

14 - Django Templates

15 - Template Context

16 - QuerySet Basics

17 - Get Item or 404 Query

18 - Dyanmic Url Routing & Patterns

19 - URL Links & Get Absolute URL

20 - Model Form & Create View

21 - Instance Update View

22 - Django Messages Framework

23 - Delete View

24 - Templates & Inheritance

25 - Setup Static Files - CSS - Javascript - Images in Django

26 - Implment Bootstrap

27 - Pagination by QuerySet

28 - File Uploads with FileField and ImageField

29 - SlugField

30 - Social Share Links

31 - Custom Template Tag

32 - Basic User Permissions

33 - Associate User to Post with a Foreign Key

34 - Using Facebook Comments

35 - Item Publish Date & Draft

36 - Model Managers & Handling Drafts

37 - Search Posts

Final Try Django 1.8 Code

try-django-19's People

Contributors

codingforentrepreneurs avatar fahadalbukhari avatar jmitchel3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

try-django-19's Issues

Slug field

When you create a new post with a title == 120 you've got an error. It's occurred because of slugfield in models.py. You need to add max_length = 120 to fix it. It's confusing for such begginers as me.

AttributeError: 'bool' object has no attribute 'last'

Hello Sir,
I am having trouble when I want to make a post. After I press the button 'SAVE' I get an error .
/posts/models.py", line 30, in upload_location
new_id = qs.last().id + 1
AttributeError: 'bool' object has no attribute 'last'

try "www.xxx.com" twice got the same page

I try to put "www.xxx,com" twice ,but I got the same page "Success",
I think it would be better to change the post function in HomeView
'''
def post(self, request, *args, **kwargs):
pform = SubmitUrlForm(request.POST)
context = {
"title": "Kirr.co",
"form": pform
}
template = "shortener/home.html"
if pform.is_valid():
#print pform.cleaned_data
new_url = pform.cleaned_data.get("url")
new2_url = validate_url(new_url)
obj, created = KirrURL.objects.get_or_create(url=new2_url)
context = {
"object": obj,
"created": created,
}
if created:
template = "shortener/success.html"
else:
template = "shortener/already-exists.html"
return render(request, template ,context)
'''

manage.py is not created

                    This option has no effect.

PS C:\dev> virtualenv .
Using base prefix 'c:\users\moti baadror\appdata\local\programs\python\python36-32'
New python executable in C:\dev\Scripts\python.exe
Installing setuptools, pip, wheel...done.
PS C:\dev> ./scripts/activate
(dev) PS C:\dev> cd..
(dev) PS C:> django-admin.py startproject dev
(dev) PS C:> cd dev
(dev) PS C:\dev> dir

Directory: C:\dev

Mode LastWriteTime Length Name


d----- 12/15/2017 10:23 PM cfehome
d----- 12/15/2017 9:47 PM Include
d----- 12/16/2017 8:21 AM Lib
d----- 12/16/2017 8:37 AM Scripts
d----- 12/16/2017 8:21 AM tcl
d----- 12/15/2017 10:20 PM yourenvname
-a---- 12/16/2017 8:21 AM 60 pip-selfcheck.json

(dev) PS C:\dev> python manage.py runserver
C:\dev/Scripts\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory
why manage.py is not creating

Class Based View

Since we are using 1.9, why are we not using Class Based View (as in Django Docs) ?

none id for new post

when you try to make new post upload_location give the instance and use its id for making a directory
but at first it is no instance and the id will be NONE and you app makes a none name directory to store that picture
it is so bad :(
Screenshot (32)

AttributeError: 'NoneType' object has no attribute 'id'

Hi .. I am having trouble when I want to make a post - . After I press the button 'SAVE' I get an error .
The console looks like this - I'm using a pyodbc database - I have checked the 'id' is there.

Can anyone help me with this?

\posts\models.py", line 27, in upload_location new_id = PostModel.objects.order_by("id").last().id + 1 AttributeError: 'NoneType' object has no attribute 'id' [25/Feb/2016 15:12:07] "POST /admin/posts/post/add/ HTTP/1.1" 500 187276 The thread 0x1040 has exited with code 0 (0x0).

attributeError when there is no post in database. i deployed to heroku there was no database there. on heroku it giving me only server error 500

AttributeError at /posts/create/
'NoneType' object has no attribute 'id'
Request Method: POST
Request URL: http://127.0.0.1/posts/create/
Django Version: 1.11.3
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'id'
Exception Location: C:\Users\Ahmed Kakar\Desktop\sublime\django\referenceCodes\src\posts\models.py in upload_location, line 37
Python Executable: C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\Scripts\python.exe
Python Version: 3.6.1
Python Path:
['C:\Users\Ahmed Kakar\Desktop\sublime\django\referenceCodes\src',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\Scripts\python36.zip',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\DLLs',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\lib',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\Scripts',
'c:\program files\python36\Lib',
'c:\program files\python36\DLLs',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1',
'C:\Users\AHMEDK1\Desktop\sublime\django\REFERE1\lib\site-packages']
Server time: Tue, 25 Jul 2017 22:33:00 +0000

AttributeError: 'bool' object has no attribute 'last'

Hi, I am having trouble when I want to make a second post.

File "/posts/models.py", line 37, in upload_location
new_id = 1
qs = PostModel.objects.order_by("id").exists()
if qs:
new_id = qs.last().id + 1
AttributeError: 'bool' object has no attribute 'last'

Can anyone help me with this?

AUTH_USER_MODEL issue

Hi guys! see posts/models.py

user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)

The problem is, please refer to django1.9 docs, syntax for AUTH_USER_MODEL = 'myapp.MyUser' , which myapp is one of the app in INSTALLED_APPS and MyUser is Django model that use as User model, does that means you have to create a user model in Post app or create a new app such as user_profile containing user model??? So I'd rather choose a user model from django.contrib.auth until the new app and/or related models created.

Another problem is AUTH_USER_MODE not set from the beginning, If you intend to set AUTH_USER_MODEL, you better set it before creating any migrations or running manage.py migrate for the first time, otherwise, you will have dependency issues. see post/migrations 0002 and 0003

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.