Database & Migrations - Django Web Development with Python 8

preview_player
Показать описание
Welcome to Part 8 of our Django web development with Python tutorial.

Remember how when you create a new app, the first thing you need to do is install it? Whenever you define new models, you want to migrate. If you are familiar with older versions of Django, the old syncdb command is deprecated. Nowadays, first you will do

Рекомендации по теме
Комментарии
Автор

It's auto incrementing because it's an AutoField :)

ThaEzioAuditore
Автор

loved the tutorials dude. Simple explanations for everything you did without all the jargon. This is awesome for people entering the python scene, me included.

Thanks dude and good luck with your work

domdinenno
Автор

About the auto increment - ot's done by AutoField <- the field automatically increments according to available IDs, so none of the parameters is responsible (just to clarify as few comments were wrong about that).
Btw, great videos! I can't wait to finish this one and Machine Learning series, both are amazing!

kacperwolkowski
Автор

You are too much, I really enjoyed every bit of the tutorials to this point

blissfultech.company
Автор

The output from python manage.py makemigrations was only
Migrations for 'blog':
0001_initial.py
- Create model Post

So it is lacking -Create model Category

Any idea why?

jaysalerno
Автор

It's auto incrementing because it's an AutoField.

PulkitKumar
Автор

The "auto-increment" is done by the "serialize" parameter.

GabrielAugendre
Автор

For those encountering the TemplateDoesNotExist error when following the video instructions, I solved like this:
path('', ListView.as_view(queryset=Post.objects.all().order_by("-date"), template_name='blog/blog.html')),
template_name paramater needed to be inside the as_view() function signature, instead of the path() function like in previous urlpatterns. Just put queryset and template_name inside the same parenthesis.
Hope this helps.

sleeplessdev
Автор

Your tutorials are amazing....

All I request for future tutorials is more on machine learning with Python.
More along the side of game dev though, ergo automated testing, genetic/neural networks ect.

I have been trying to use PyAutoGUI to interface with a gameboy advance emulator but to no avail I can't figure it out.
Will keep trying though
Anyway sorry to bother and thank you again for all the time you give to these tutorials...

arcspwan
Автор

hello
I hava a Django (version 2.1.7) app on a windows which was set up with sqlite3 as the db, but it's going to production so I'm migrating the tables to oracle (OracleXE112)on the server, i don't care about the data just the tables so when I run python manage.py migrate
I get ORA-2000 Error: missing ALWAYS keyword
, Unable to create the django_migrations table (ORA-02000: missing ALWAYS keyword)

I'm new to django, what am i missing?


please help me, and thank you.

ayoubbouchachia
Автор

@sentdex thanks for tutorial. I got a problem, maybe you can suggest something. I have a working Django project with different apps. I was changing something and deleted all db. Now when doing makemigrations and migrate, errors are coming out: appname_modelname relation doesn't exists. I tried to create those tables manually, but no solution. My db is PostGr.

giorgijav
Автор

does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import. I get this error when I try to run the migrations, I can not seem to find where I went wrong. I checked all of the URL pages in blog and mysite.

It says it is in the mysite\blog\urls.py path, and I have tried copying and pasting that part from your source code to try an fix it and no luck so far! What could be going wrong?

phizy_
Автор

hi,
i have a little problem.
how can you add fields in model runtime while website is running

vishalkale
Автор

if you was to change the models.py file would you have to makemigrations again or is they an update

Andy..
Автор

My table will not line up. Blog is on the same line as Home. I used the fix from a couple videos back about flex column and nav-item. It worked until this video and I can't find what changes caused this.

ManOak
Автор

Solved my blog/blog.html, blog/post_list.html" by taking the "/mysite/blog/template/" and the "blog/blog.html" (both folder and html file) and moved them under "/mysite/personal/templates". I tried to check my urls and settings according to the video instructions, but moving file seemed to work for me as it was giving error for not finding it in "personal/templates". I am using django version 2.1.2.

Naapi
Автор

hello do you know where i can possibly find the documentation on all the .objects.all() and related commnads plz??..i have a docs folder in my django project with txt docs and if and when i add docs or modify txt in the docs ..i dont see it update in my views in the web browser..anyone there?/, , thxz

lucioiams
Автор

File Scripts Jani\Django\landco\blog\urls.py", line 8
template_name="blog/blog.html")),
^
SyntaxError: unexpected EOF while parsing

Hi, it gives me this error when i try to load the page after this tutorial.
Can u please explain or help me why im getting this message.thnx in advance.

martjandedi
Автор

I am getting following error any solution for this??


from .models import PostForm
ImportError: cannot import name 'PostForm' from 'blog.models'

sepspatel
Автор

I'm having trouble with this, as I'm getting this error on command(mac):

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1041e9c80>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 407, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors =
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 255, in check

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 414, in url_patterns
raise
The included URLconf '<module 'blog.urls' from does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

mmma