Re: Trouble changing from sqlite3 to postgres
The error is probably in code you wrote that uses the date field. Can you post the full traceback? That will let us see where the caller was that created the problem. On Tuesday, February 17, 2015 at 3:13:30 PM UTC-5, tony@gmail.com wrote: > > I have written a simple Django app (my first) that works with sqlite3 > database. > I want to change to postgres, but when I run the Django 1.7 migration > utility with the command > "python manage.py migrate" > > I get the error: > psycopg2.ProgrammingError: column "date" cannot be cast automatically > to type integer > > Which is occuring in: > File > "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line > 65, in execute > return self.cursor.execute(sql, params > > I am not sure how to track down the problem. > I am running Slackware Linux. > > My models.py file is as follows: > > > from django.db import models > import datetime > > # Create your models here. > > class Location(models.Model): > >class Meta: > unique_together = ("lat", "lng") > >lat = models.DecimalField(max_digits=8, decimal_places=5) >lng = models.DecimalField(max_digits=8, decimal_places=5) >name = models.CharField(max_length=200, unique=True) > >def __str__(self): > return "%s: %d %d" % (self.name, self.lat, self.lng) > > class Observation(models.Model): > >date = models.DateField() >location = models.ForeignKey(Location) >observer = models.CharField(max_length=50) >temperature = models.FloatField(default=0.0) >photo= models.ImageField(default="tower.jpg", > upload_to="uploaded_photos") > >def __str__(self): > return self.observer > = > > The DATABASE part of my settings.py file is as follows > where I have commented-out the old sqlite3 part: > > - > DATABASES = { > > # 'default': { > # # sqllite3 > # 'ENGINE': 'django.db.backends.sqlite3', > # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), > # } > ># For postgres: > #'django.db.backends.postgresql_psycopg2', > # USER, PASSWORD, HOST also needed > # Inside postgres, "CREATE DATABASE database_name" > > 'default': { > 'ENGINE': 'django.db.backends.postgresql_psycopg2', > 'NAME': 'app_1_db', > 'USER': 'bill', > 'PASSWORD': 'bill', > 'HOST': '127.0.0.1', > 'PORT': '5432', > } > > } > > > > Please let me know if you have ideas. > > Thanks. > > -- 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/df155cf9-9ba7-42fd-b9b2-2a78f433ca21%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Default UserCreationForm and UserChangeForm hard-coded to User; is this required?
I'm not sure if this is a bug or intended, hence my asking here before adding to the bug database. In django.contrib.auth.forms, the UserCreationForm and UserChangeForm refer several times to the User model directly, rather than using get_user_model(). This means that when using a different model for the user model, you can't use the Django admin unless you create a custom form that overrides this behavior. When I change this in the Django codebase to refer to get_user_model(), it works just fine -- both with the standard Django User model and with a custom user model. So, it *appears* that this could work fine as a code fix for Django. It's possible, though, that there's a subtlety I'm missing and that these should continue to refer to User proper. Thoughts, anyone? -- 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/6e01619f-d9cb-403c-9cd1-0976b2cd5c47%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Default UserCreationForm and UserChangeForm hard-coded to User; is this required?
stion about user creation forms will be the least of your > concerns given the bugs you'll likely run into. The only reason I would > recommend doing so would be for learning the internals in a sandbox or > supplying a patch to commit for a bug/improvement, also in a sandbox. > > HTH, > > -James > On Jan 5, 2015 7:04 PM, "Joel Burton" > wrote: > >> I'm not sure if this is a bug or intended, hence my asking here before >> adding to the bug database. >> >> In django.contrib.auth.forms, the UserCreationForm and UserChangeForm >> refer several times to the User model directly, rather than using >> get_user_model(). >> >> This means that when using a different model for the user model, you >> can't use the Django admin unless you create a custom form that overrides >> this behavior. >> >> When I change this in the Django codebase to refer to get_user_model(), >> it works just fine -- both with the standard Django User model and with a >> custom user model. So, it *appears* that this could work fine as a code fix >> for Django. >> >> It's possible, though, that there's a subtlety I'm missing and that these >> should continue to refer to User proper. >> >> Thoughts, anyone? >> >> -- >> 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...@googlegroups.com . >> To post to this group, send email to django...@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/6e01619f-d9cb-403c-9cd1-0976b2cd5c47%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/6e01619f-d9cb-403c-9cd1-0976b2cd5c47%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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/5330319a-f543-44f8-890c-15bed87c5d08%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.