Could you please post actual traceback you get?

Because it feels that you had different model when you ran syncdb, changed something later but did not modified database schema to comply with your model(s).

And if model doesn't have explicit PK django should create one named "id", it shouldn't be using first field defined.

--

Jani Tiainen

On 26.10.2011 19:03, Shark wrote:
There is problem in this project
I use Auth User and foreign key in anther table  "geoFeeds" and when
adding data to table gepFeed am error happened

column user_id is not unique

when changing the userId it add one time but the second time it fails
and give this error I don't know why

this is the code

models.py

from django.db import models
from django.contrib.auth.models import User

class GeoFeed(models.Model):
     user = models.ForeignKey(User, unique=False)
     link = models.URLField()
     name = models.CharField(max_length=100)
     def __unicode__(self):
         return self.id


and this is the function that add feeds in view



def addFeed(request):
     ok = False

     if request.method == 'POST': # if the form has been submitted
         fname = request.POST.get('fname', '') # feed name
         flink = request.POST.get('flink', '') # feed link

         if fname is not None and flink is not None:
             # save
             u = User.objects.get(pk = 2) # pre-defined user till amr
finishes user-sys
             f = GeoFeed(user = u, link = flink, name = fname)
             f.save()

     return render_to_response('add_feed.html', {'ok': ok},
RequestContext(request))


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to