Answer the question
In order to leave comments, you need to log in
No such column: question_profile.user_id, django-profile - how to solve the problem?
Installed django-profile and I get this error.
#models.py
class Question(models.Model):
title = models.CharField(max_length=120)
content = models.TextField()
pub_date = models.DateTimeField(blank=True, null=False, auto_now_add=True)
author = models.OneToOneField(User)
views = models.IntegerField(default=0)
slug = models.SlugField(max_length=240, blank=True)
tag = TaggableManager()
def __unicode__(self):
return self.title
def save(self, **kwargs):
if not self.pk:
self.date_added = date.today()
if self.title and not self.slug:
self.slug = slugify(self.title)
super(Question, self).save(**kwargs)
GENDER_CHOICE = (('F', _('Female')), ('M', _('Male')),)
class Profile(BaseProfile):
firstname = models.CharField(max_length=255, blank=True)
surname = models.CharField(max_length=255, blank=True)
gender = models.CharField(max_length=1, choices=GENDER_CHOICE, blank=True)
birthdate = models.DateField(default=datetime.date.today(), blank=True)
url = models.URLField(blank=True)
about = models.TextField()
avatar = models.ImageField(upload_to='media/uploads')
abstract = True
def has_avatar(self):
return Avatar.objects.filter(user=self.user, valid=True).count()
def __unicode__(self):
return _("%s's profile") % self.user
def get_absolute_url(self):
return reverse("profile_public", args=[self.user])
class BaseProfile(models.Model):
"""
User profile model
"""
user = models.ForeignKey(User, unique=True)
creation_date = models.DateTimeField(default=datetime.datetime.now)
country = CountryField(null=True, blank=True)
latitude = models.DecimalField(max_digits=10, decimal_places=6, blank=True, null=True)
longitude = models.DecimalField(max_digits=10, decimal_places=6, blank=True, null=True)
location = models.CharField(max_length=255, blank=True, null=True)
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/profile/
Django Version: 1.6.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'question',
'south',
'taggit',
'hitcount',
'registration',
'userprofile')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/userprofile-0.6-py2.7.egg/userprofile/views.py" in overview
109. profile, created = Profile.objects.get_or_create(user=request.user)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in get_or_create
154. return self.get_queryset().get_or_create(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get_or_create
376. return self.get(**lookup), False
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
304. num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __len__
77. self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fetch_all
857. self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
220. for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in results_iter
713. for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py" in execute
451. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /accounts/profile/
Exception Value: no such column: question_profile.user_id
Answer the question
In order to leave comments, you need to log in
Did you look in db? Is there a column there? Try dropping the db and doing syncdb again.
Before it's too late, move to Django 1.7, they added migrations there, very convenient.
I am not familiar with this plugin, but perhaps the model for it needs to be inherited from its own class, and not from the standard one?
The fact is that I did both syncdb and migration not vidiot he string user
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question