It's telling you that your default "date" value will be the same for every 
instance of "Journal" you create (essentially it'll be the time when the 
migration is created), when you probably intend it to be the time each Journal 
entry is created.

Try changing default=timezone.now() to default=timezone.now (without the 
parens). That should resolve the warning and yield more desirable behavior. 
Even better, remove the default and add auto_now_add=True 
(https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.DateField.auto_now_add)

_Nik
On 9/22/2015 5:20:48 PM, Alex Kleider <aklei...@sonic.net> wrote:
Although at the intermediate level with regard to Python,
I'm just beginning with Django, running Ubuntu 14.4LTS
in a venv established by
$ virtualenv -p python3 venv

I set up a journal app with a models.py file and then
changed some of the fields. Now I can't seem to get rid of
the following warning:
WARNINGS:
journal.Journal.date: (fields.W161) Fixed default value provided.
HINT: It seems you set a fixed date / time / datetime value as default
for this field. This may not be what you want. If you want to have the
current date as default, use `django.utils.timezone.now`

I deleted the db.sqlite3 file thinking that would allow me to start
fresh but somehow django remembers what was there before although it's
not there now:
file journal/models.py:
from django.db import models
from django.utils import timezone

class Journal(models.Model):
"""
Each instance represents a journal entry to be stored in the
Journal table. The automatically created auto-incrementing
primary key serves as the entry number.
"""
date = models.DateTimeField(default=timezone.now())
user = models.CharField(max_length=24)
description = models.CharField(max_length=256)
def __str__(self):
ret = [" #{:0>3} on {:<12} by="" {}."="">
.format(self.id,
self.date.strftime('%Y-%m-%d %H:%M'),
self.user)]
for line in self.description.split('\n'):
ret.append(" {}".format(line))
return '\n'.join(ret)

Any advice would be appreciated.
Alex

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/25bfa6241296e00dca1e76be74a85e04%40sonic.net.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff412899-279f-4747-b09d-c2a2d56e1462%40getmailbird.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to