RuntimeWarning: DateTimeField received a naive datetime

I m trying to send a simple mail using IPython. I have not set up any models still getting this error. What can be done? Error : /home/sourabh/Django/learn/local/lib/python2.7/site-packages/django/db/models/fields/init.py:827: RuntimeWarning: DateTimeField received a naive datetime (2013-09-04 14:14:13.698105) while time zone support is active. RuntimeWarning) Tried : The first step is to add USE_TZ = True to … Read more

How to define two fields “unique” as couple

Is there a way to define a couple of fields as unique in Django? I have a table of volumes (of journals) and I don’t want more then one volume number for the same journal. class Volume(models.Model): id = models.AutoField(primary_key=True) journal_id = models.ForeignKey(Journals, db_column=’jid’, null=True, verbose_name = “Journal”) volume_number = models.CharField(‘Volume Number’, max_length=100) comments = … Read more

Extending the User model with custom fields in Django

What’s the best way to extend the User model (bundled with Django’s authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I’ve already seen a few ways to do it, but can’t decide on which one is the best. 15 s 15 The least … Read more

What’s the difference between django OneToOneField and ForeignKey?

What’s the difference between Django OneToOneField and ForeignKey? 1Best Answer 11 Differences between OneToOneField(SomeModel) and ForeignKey(SomeModel, unique=True) as stated in The Definitive Guide to Django: OneToOneField A one-to-one relationship. Conceptually, this is similar to a ForeignKey with unique=True, but the “reverse” side of the relation will directly return a single object. In contrast to the … Read more

How to filter empty or NULL names in a QuerySet?

I have first_name, last_name & alias (optional) which I need to search for. So, I need a query to give me all the names that have an alias set. Only if I could do: Name.objects.filter(alias!=””) So, what is the equivalent to the above? 9 s 9 You could do this: Name.objects.exclude(alias__isnull=True) If you need to … Read more

How can I upgrade specific packages using pip and a requirements file?

I’m using pip with a requirements file, in a virtualenv, for my Django projects. I’m trying to upgrade some packages, notably Django itself, and I’m getting an error about source code conflicts: Source in <virtualenv>/build/Django has version 1.2.3 that conflicts with Django==1.2.4 (from -r requirements/apps.txt (line 3)) That’s after updating the version number of Django … Read more