Friday, June 30, 2017

Re: Database validation error - Even after manage.py flush.

Hey man, if you have any problem, ALWAYS check the django documentation in the first place. IMO, its preaty extensive and complete, and always helped me through the 4~5 years I'm developing with django.

After that, stackoverflow always help ( =P ).

And if the things still goes badly, django-users will help too. The answer might take a while, but will always come (I gess).

2017-06-30 15:47 GMT-03:00 <pieceofkayk2718@gmail.com>:
Hey thanks for that extra input.  I'm currently a student at NMSU making an educational app for NASA'S Planetary Data Systems.  Right now I'm the only student working on it and the only person in my building that knows Django (which I'm learning on the job).  I'm making a blog alongside my app to supplement the Django tutorials and reading material we have for the following students we bring onto this project.  I've read through my books like 20 times already and since they're beginner level books there really isn't too much in depth material about migrations or databases in Django.  So this post will definitely be pinned in our student blog.  You the man Guilherme! 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f904720c-1ecf-45ae-abac-e7dc5da819d5%40googlegroups.com.

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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs3Lp5Mp3cERE%2B21vQLypFYXXt_NfrWPOvbZic1%2Bu-fBt98DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

Hey thanks for that extra input.  I'm currently a student at NMSU making an educational app for NASA'S Planetary Data Systems.  Right now I'm the only student working on it and the only person in my building that knows Django (which I'm learning on the job).  I'm making a blog alongside my app to supplement the Django tutorials and reading material we have for the following students we bring onto this project.  I've read through my books like 20 times already and since they're beginner level books there really isn't too much in depth material about migrations or databases in Django.  So this post will definitely be pinned in our student blog.  You the man Guilherme! 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f904720c-1ecf-45ae-abac-e7dc5da819d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

Np man, always glad to help!

Just to seal the case, that happened because django dont edit the migration files itself (well, not through the normal cycle of "makemigrations">"migrate"). You generated a migration with an invalid config, and didnt even mattered if you tried to correct that "default value" and generated another migration, the incorrect migration would still be there.

Another thing that should work would be to generate another migration with the fix for the default value, and use the "squash migrations" feature, which would persist only the most recent/relevant "default value" for that field.

2017-06-30 15:16 GMT-03:00 <pieceofkayk2718@gmail.com>:

Oh dude you are officially my hero!  I didn't even think about the migration files.  That totally worked.  And thank you thank you thank you =D <3.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c7ce3e4c-157a-48e1-9da1-d6e0bfb86715%40googlegroups.com.

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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs3Lp6yKVTYE4acdRdZgoMu3a8vBbvFq6e56a2PPYZU0A3w9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.


Oh dude you are officially my hero!  I didn't even think about the migration files.  That totally worked.  And thank you thank you thank you =D <3.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c7ce3e4c-157a-48e1-9da1-d6e0bfb86715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

Just to clarify:

Change the default value to "False";
Delete the migration file (0012_auto_20170630_1027);
Run makemigrations;
Run migrate.

2017-06-30 15:08 GMT-03:00 Guilherme Leal <lealhugui@gmail.com>:
Have you re-ran the "makemigrations"? If that didnt work, delete the migration file (0012_auto_20170630_1027) and run "makemigrations" again.

2017-06-30 15:04 GMT-03:00 <pieceofkayk2718@gmail.com>:
I also did the "If all else fails, reboot your computer" and still have the same problem.  Haha.  I think I'm screwed.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a50cc341-34d5-48e2-880a-f859689a76e5%40googlegroups.com.

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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs3Lp5o%2B9ROf-960kA_x%3DSgxDYLXS2OMeJky91hCy0-iJXSwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

Have you re-ran the "makemigrations"? If that didnt work, delete the migration file (0012_auto_20170630_1027) and run "makemigrations" again.

2017-06-30 15:04 GMT-03:00 <pieceofkayk2718@gmail.com>:
I also did the "If all else fails, reboot your computer" and still have the same problem.  Haha.  I think I'm screwed.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a50cc341-34d5-48e2-880a-f859689a76e5%40googlegroups.com.

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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs3Lp7fesXtcA0C20om73gN0PEdKZSYA8U8CYpz8cakSpRjXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

I also did the "If all else fails, reboot your computer" and still have the same problem.  Haha.  I think I'm screwed.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a50cc341-34d5-48e2-880a-f859689a76e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

Yes.  At first I tried setting default=True or default=False for my BooleanField and kept getting the same error.  So I went back in, deleted the model, tried again, got the same error.  Then I deleted my db sqlite3 file, made new migrations, migrated (with the model not even a part of my models.py anymore) and am still getting this error. 

On Friday, June 30, 2017 at 11:37:26 AM UTC-6, Guilherme Leal wrote:
>>>>>>>django.core.exceptions.ValidationError: [u"'' value must be either True or False."]


Have you tried to set the default value of the BooleanField as True or False? BooleanFields must have a valid boolean as default value and so happends that empty string is not a valid boolean.

Change the default value to False (as exemple), run the migration again, and it should work.


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07fe41c0-25f9-491a-8af8-b6b4c20c4a09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database validation error - Even after manage.py flush.

>>>>>>>django.core.exceptions.ValidationError: [u"'' value must be either True or False."]


Have you tried to set the default value of the BooleanField as True or False? BooleanFields must have a valid boolean as default value and so happends that empty string is not a valid boolean.

Change the default value to False (as exemple), run the migration again, and it should work.

2017-06-30 14:23 GMT-03:00 <pieceofkayk2718@gmail.com>:
So I made the ultimate error.  I put a BooleanField in my models.py, when I made migrations I set default col value to the empty string ''.. Then I migrated and got a validation error.  However, I have tried to delete the model containing BooleanField, delete my database file, and I even ran manage.py flush and cannot seem to get rid of this error.  If anyone has any experience with BooleanField errors please help.  My traceback from my terminal is below:

  Applying build_a_bundle.0012_auto_20170630_1027...Traceback (most recent call last):
 
File "manage.py", line 22, in <module>
    execute_from_command_line
(sys.argv)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility
.execute()
 
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
   
self.fetch_command(subcommand).run_from_argv(self.argv)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
   
self.execute(*args, **cmd_options)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output
= self.handle(*args, **options)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial
=fake_initial,
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state
= self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state
= self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state
= migration.apply(state, schema_editor)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation
.database_forwards(self.app_label, schema_editor, old_state, project_state)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/operations/fields.py", line 86, in database_forwards
    field
,
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 238, in add_field
   
self._remake_table(model, create_field=field)
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 113, in _remake_table
   
self.effective_default(create_field)
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", line 229, in effective_default
   
default = field.get_db_prep_save(default, self.connection)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 766, in get_db_prep_save
    prepared
=False)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 758, in get_db_prep_value
    value
= self.get_prep_value(value)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 1039, in get_prep_value
   
return self.to_python(value)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 1032, in to_python
   
params={'value': value},
django
.core.exceptions.ValidationError: [u"'' value must be either True or False."]



--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dc30ad69-a4b8-4163-8f7e-7a5d0d42fbd8%40googlegroups.com.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs3Lp4EHC3xqzqK2EJWGrZ0cR1r7w9q1ZpFBCxFoRz-OS67Hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Database validation error - Even after manage.py flush.

So I made the ultimate error.  I put a BooleanField in my models.py, when I made migrations I set default col value to the empty string ''.. Then I migrated and got a validation error.  However, I have tried to delete the model containing BooleanField, delete my database file, and I even ran manage.py flush and cannot seem to get rid of this error.  If anyone has any experience with BooleanField errors please help.  My traceback from my terminal is below:

  Applying build_a_bundle.0012_auto_20170630_1027...Traceback (most recent call last):
 
File "manage.py", line 22, in <module>
    execute_from_command_line
(sys.argv)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility
.execute()
 
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
   
self.fetch_command(subcommand).run_from_argv(self.argv)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
   
self.execute(*args, **cmd_options)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output
= self.handle(*args, **options)
 
File "/usr/lib64/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial
=fake_initial,
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state
= self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state
= self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state
= migration.apply(state, schema_editor)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation
.database_forwards(self.app_label, schema_editor, old_state, project_state)
 
File "/usr/lib64/python2.7/site-packages/django/db/migrations/operations/fields.py", line 86, in database_forwards
    field
,
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 238, in add_field
   
self._remake_table(model, create_field=field)
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 113, in _remake_table
   
self.effective_default(create_field)
 
File "/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", line 229, in effective_default
   
default = field.get_db_prep_save(default, self.connection)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 766, in get_db_prep_save
    prepared
=False)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 758, in get_db_prep_value
    value
= self.get_prep_value(value)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 1039, in get_prep_value
   
return self.to_python(value)
 
File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 1032, in to_python
   
params={'value': value},
django
.core.exceptions.ValidationError: [u"'' value must be either True or False."]



--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dc30ad69-a4b8-4163-8f7e-7a5d0d42fbd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

add users to google group django

I have a quick question about handling email updates using Django. My organization uses a Google Group to send mass emails to those added to the email list, and I was looking to add a 'sign up' widget to the footer of the website (It's a non-buisness Google Group). Is it possible to utilize Google Group's API and Django to create a system where Django automatically adds emails to the Google Group? If so, how do you all suggest I go about implementing the feature?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/730d41bf-4fed-4626-be42-8b007ca26ddf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Keep logged in accross Sites

Hello,

I'm using Django Sites framework to hadle different sites, with the same users. 

I'd like to add a link to switch between my sites, but I don't want to get redirected to login view. What is the best way? should I add a view that logs the user in the destination site and redirect?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/896d69c6-40da-4c85-bb0d-91c589ba7924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: SelectDateWidget when DateField is not required

I can't reproduce a crash. If I select only a month, I see a validation error, "Enter a valid date."

On Monday, June 12, 2017 at 6:28:29 AM UTC-4, Nonverbis M wrote:

Django 1.11.2

I'd like to use SelectDateWidget.


class FrameDate(models.Model):
    through_date
= models.DateField(null=True,
                                    blank
=True,
                                    verbose_name
=_("through"))
   
...

class FrameDateForm(ModelForm):

   
def clean_through_date(self):
       
pass # Breakpoint

   
class Meta:
            model
= FrameDate
            exclude
= []

            years
= range(1800, datetime.datetime.now().year + 1)

            widgets
= {
               
'frame': forms.HiddenInput(),
               
'from_date': forms.SelectDateWidget(years=years),
               
'through_date': forms.SelectDateWidget(years=years)
           
}



As we can see, this DateField is not required. And have an empty choice at the top of the list ("---").

The problem is that when a user inputs only a month we'll get ValueError springing out to the user in case of Debug=True.

There is that method clean_through_date and the break point in it. But in case of incomplete set of month, day and year the program will not even call this clean_through_date() method. This method is called in two cases:

1) if the through_date is completely empty.

2) if it is completely filled.

If it is partially filled, form validation is ignored completely. The program explodes at CreateView.

Could you comment on it? And give me a kick here: how to warn the user that s/he must either fill month, day and year or don't touch the through_date at all.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a1744ff0-11d9-4e04-ad18-393765e4bfec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.