I am new to Django, so i don't know if the answer is obvious. I created models.py inside a project and when i tried syncDB, it did not create the tables defined in models.py. Only when i create models.py inside an app and after registering the app with INSTALLED_APPS, the tables are getting created on syncDB.
Is this is how Django works? Or am i missing something.
Both sources agree that you should create a separate app in the following situations: If you plan to reuse your app in another Django project (especially if you plan to publish it for others to reuse). If the app has few or no dependencies between it and another app.
Yes that is possible, but a lot of ways how Django can help with webdevelopment are based on its models. For example based on a model Django can make a ModelForm [Django-doc] to automate rendering HTML forms that map to the model, validating user input, and saving it to the database.
What is Django? Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.
Django only syncs what's defined in INSTALLED_APPS
. The name is pretty straight-forward. Django's going to look for at least a module (directory with an __init__.py
) with a models.py
file inside. So yes, you need an "app", but that app can be just a directory with just __init__.py
and models.py
files inside.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With