Django not creating tables for an installed app - django

My django site was functioning before I installed Lion and had to reinstall everything related to development. Since then, I have deleted and recreated my database, but one of my two installed apps is being ignored in syncdb. Those tables are not present in my database.
This post suggested there might be an import error. I can import the app in question using manage.py shell, so I don't think that's it.
Both apps are definitely installed (verified by debug toolbar). Any other suggestions? I'm relatively new to Django, having been mostly an iOS developer for the past couple of years.

https://docs.djangoproject.com/en/dev/ref/models/options/#app-label
If a model exists outside of the standard models.py (for instance, if the app’s models are in submodules of myapp.models), the model must define which app it is part of.
What it doesn't mention is that they also have to be imported somewhere during the model registration phase.

Related

reusable app (package) in Django - how to add extra models

I am writing a small package that extends the django app that is used by many of my colleagues locally. So right now they can simply add it via pip, and then they add this extension in INSTALLED_APPS in settings.py.
But the problem is that I can't add the new models to this extension (or at least I don't figure out yet how to do it correctly) because then the guys who would like to use my extension, have to sync their database or make migrations so their database contains the models needed for extension.
Is it possible (and right thing to do) to add new models to the current django project 'silently' as soon as the user adds the app to INSTALLED_APPS?

Uninstalling an app breaks old migration

I've stopped using a 3rd party app which I no longer need so I've uninstalled from my virtualenv. However, that causes all the old migrations which reference models from that app from failing when I migrate.
from menu.models import MenuItem
ImportError: No module named menu.models
The only two options I can think of are to either leave the 3rd party app installed just to satisfy the migration or to edit the old migration to remove the reference to the now defunct app.
Neither seem ideal. Any other way I've not thought of?
According to Django Migrations Historical Models docs:
... the base classes of the model are just stored as pointers, so you
must always keep base classes around for as long as there is a
migration that contains a reference to them.
So, you should keep historical apps in your Virtualenv till you remove the migration files that have references to historical models.
The ways to remove migrations files are:
Squashing Migrations, or
Removing migration files and migrations records in the database. CAUTION: Do NOT do that if you are not really sure what are you doing, look at this answers for more info: How to reset migrations in Django 1.7?.

CMS for Django when upgrading app from 1.5.5 to 1.7.1

I have a huge... challenge in front of me. For about a week or two I've been migrating 1.5.5 django project to 1.7.1. A huge jump, many deprecated variables, methods and so on.
In 1.5.5 there were some south migrations done but not everywhere, as it was not implemented from the beginning. So let's say there are no migrations, they have to be created.
Also there is a wish to add a cms to the already upgraded project, but with django-cms-3.0.7 I constantly encounter some issues with migrations, south existing etc.
Is there a CMS that I can use with this app that won't be bothered by migrations and django version?
All I want to edit is the static content (text, images, maybe adding videos) before user logon. No integration with models. Just some info pages.
Any suggestions?
A maybe oversimplified solution for this could be django-front. Create your static pages and add the fields you want to edit. You edit it with a wysiwyg editor. I use it for my terms of service/privacy policy.
You will probably be always bothered by migrations and django version when using an app that brings extra functionality, but the apps should not be hard to upgrade and normally they have a warning/walk through when an important change on their arquitecture/functionality has happened.
That being said, i don't think migrations change dramatically now. The change to include them in the django project was an important (and needed) one.
If you want something even more simple (and time resistant) just create a model for your pages and render it on your template:
class Content(models.Model):
html_content = models.TextField()
image_content = models.ImageField()
Register that model to your admin and that should do the trick. For simple applications this may be enough.

Can I add any column after I created My database?

I created my database using python manage.py syncdb And I tried to add another attribute to my model called created_date My site gives error. And I deleted my db.sqlite3 file Then reorganize my model Then error went. I want to know is this correct
As the comment says migrations are the way to do this. Native migrations were only introduced in Django 1.7 but, since you're using syncdb, I'm guessing you're using an earlier version.
For earlier versions of Django you need a third-party app called South to handle migrations for you. This will then let you change your database after creation fairly painlessly in most cases.

django modeltranslation registers "0" models

I have a Django project that employs modeltranslation. On the development box, it registers 10 models and works flawlessly.
On the production server, when started it notifies that it has registered "0" models (instead of 10) and doesn't throw any exceptions. However when any admin page that shows a should-be-registered model is visited, the NotRegistered exception is thrown.
All non-admin pages, and admin pages that don't include translated models work without problems.
Suggestions are highly appreciated.
Moving the modeltranslation folder from the project folder into the packages folder resolved the issue.
have a look into your database, i would bet that "syncdb" did not add the required colums/tables
if you have no production data on the database: simple delete it and re-sync it