Re: starting afresh
On 2015-09-22 19:04, James Schneider wrote: Did you delete the previously created migration files? . There should be a 'migrations' folder that was created inside of your app. You can whack the whole folder, it will be created next time you run 'makemigrations'. Indeed, it is there! (I could have sworn that I had checked but I must have only looked in the project folder and thought I had looked in both it and the app folder. Thank you again and sorry to have bothered. cheers, 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/4c023a21319099ef88be6cf61ab338e7%40sonic.net. For more options, visit https://groups.google.com/d/optout.
Re: starting afresh
>> Did you delete the previously created migration files? Django won't ask >> those questions unless previous migration files exist. If you're starting >> with a fresh database, you probably should. >> >> -James > > > Ah, ha! That must be it. Much appreciate the tip. > ...but the problem is I can't find the migration files in order to delete them. > Where are they? > A google search didn't get me far. > Thanks, Alex There should be a 'migrations' folder that was created inside of your app. You can whack the whole folder, it will be created next time you run 'makemigrations'. -James -- 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/CA%2Be%2BciUoHq5_Uu_gHisAM8tkUfhZRzPd%2BFbn4j_iTXgi7AE9Vw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: starting afresh
On 2015-09-22 18:12, James Schneider wrote: Did you delete the previously created migration files? Django won't ask those questions unless previous migration files exist. If you're starting with a fresh database, you probably should. -James Ah, ha! That must be it. Much appreciate the tip. ...but the problem is I can't find the migration files in order to delete them. Where are they? A google search didn't get me far. Thanks, 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/baf7f7495fcaf03609ae5eb67a929411%40sonic.net. For more options, visit https://groups.google.com/d/optout.
Re: starting afresh
> Now I have another: I'm unable to make django forget what I've done before! > > I still get the following error: > """ > (venv)alex@x301:~/Py/debk$ ./manage.py makemigrations > Did you rename lineitems.acount to lineitems.dc_type (a CharField)? [y/N] y > You are trying to add a non-nullable field 'acnt_number' to lineitems without a default; we can't do that (the database needs something to populate existing rows). > Please select a fix: > 1) Provide a one-off default now (will be set on all existing rows) > 2) Quit, and let me add a default in models.py > Select an option: > """ > As mentioned before, I deleted my data base but the error persists > *snip* > How does Django even know what was in this file before, let alone why should it now care? > Did you delete the previously created migration files? Django won't ask those questions unless previous migration files exist. If you're starting with a fresh database, you probably should. -James -- 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/CA%2Be%2BciUwgWEEP_S7Ri%2BcjAPkceYh6REt2fEw_W7iMgCod8Hbxw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: starting afresh
On 2015-09-22 17:29, Nikolas Stevenson-Molnar wrote: 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) Thank you,_Nik. That did indeed resolve this issue and I am grateful to you. Now I have another: I'm unable to make django forget what I've done before! I still get the following error: """ (venv)alex@x301:~/Py/debk$ ./manage.py makemigrations Did you rename lineitems.acount to lineitems.dc_type (a CharField)? [y/N] y You are trying to add a non-nullable field 'acnt_number' to lineitems without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows) 2) Quit, and let me add a default in models.py Select an option: """ As mentioned before, I deleted my data base but the error persists Here's journal/models.py currently: from django.db import models ACCOUNT_CODE_LENGTH = 4 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(auto_now_add=True) 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) class LineItems(models.Model): entry = models.ForeignKey(Journal) acnt_number = models.CharField(max_length=ACCOUNT_CODE_LENGTH) dc_type = models.CharField(max_length=1) # D(ebit or C(redit amount = models.IntegerField() # Pennies i.e. $nn.dd * 100 def __str__(self): if self.dc_type.upper() == 'D': return ("{:>8}:{:>10,.2f}Dr" .format(self.acnt_number, self.amount/100.0)) elif self.dc_type.upper() == 'C': return ("{:>8}:{:>20,.2f}Cr" .format(self.acnt_number, self.amount/100.0)) else: return ("Huston, we have a problem!") How does Django even know what was in this file before, let alone why should it now care? -- 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/fcf47bd983b673fca2c308d4f3f63b22%40sonic.net. For more options, visit https://groups.google.com/d/optout.
Re: starting afresh
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 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.
starting afresh
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.