Re: Integrity Error: column username is not unique

2014-02-26 Thread Ravikumar Patil
> from django.shortcuts import get_object_or_404 > > get_object_or_404(User,username = request.user) > -- 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

Re: Integrity Error: column username is not unique

2013-03-28 Thread Jaimin Patel
If the user is marked as deleted and we want to do soft delete.What can we do to have the username available again for use. Can we just mask the deleted usernames with some random string so that the actual username can be used? On Sunday, June 24, 2012 10:36:02 AM UTC-4, Dhivya wrote: > > Hi,

Re: Integrity Error: column username is not unique

2012-06-24 Thread Dhivya
Hi, username field in django.contrib.auth.User model is unique. Probably, the username you are trying to save already exists. In your view, you might want to check, try: username = User.objects.get(username=form.cleaned_data['username']) except ObjectDoesNotExist: #create user new

Re: Integrity Error

2011-08-26 Thread Thomas Orozco
Glad I could help! Le 26 août 2011 12:53, "Torsten" a écrit : > Thanks Thomas you helped me a lot these are my first step in python > and django. > And I really starting to like it > > Torsten > > On 26 Aug., 12:23, Thomas Orozco wrote: >>

Re: Integrity Error

2011-08-26 Thread Torsten
Thanks Thomas you helped me a lot these are my first step in python and django. And I really starting to like it Torsten On 26 Aug., 12:23, Thomas Orozco wrote: > While we're at it, here are a few suggestions. > So long as you can, you should use unicode inside python

Re: Integrity Error

2011-08-26 Thread Thomas Orozco
While we're at it, here are a few suggestions. So long as you can, you should use unicode inside python code. The main logic would be that input should be converted to unicode as soon as possible, and that output should be encoded (likely to UTF-8) as late as possible. Consequently, you might

Re: Integrity Error

2011-08-26 Thread Thomas Orozco
Actually, the line "invoice = models.ForeignKey(Invoice)" tells Django "An invoice item should always be attached to an invoince". You must realize that models are what they claim to be... models. They are not items of their own, they just define how you would model a particular item in your

Re: Integrity Error

2011-08-26 Thread Torsten
Thanks Thomas your are right concerning the sum there is no need for that. But you say: Your invoice items have no invoice attribute, as the error says. Isn't this line which defines the attribute ? invoice = models.ForeignKey(Invoice) Thanks Torsten On 26 Aug., 11:41, Thomas Orozco

Re: Integrity Error

2011-08-26 Thread Thomas Orozco
That would be blank = True Le 26 août 2011 11:58, "Kejun He" a écrit : > Sometime, set null = true would allow a field to be empty > > On Fri, Aug 26, 2011 at 5:41 PM, Thomas Orozco wrote: > >> Your invoice items have no invoice attribute, as the

Re: Integrity Error

2011-08-26 Thread Kejun He
Sometime, set null = true would allow a field to be empty On Fri, Aug 26, 2011 at 5:41 PM, Thomas Orozco wrote: > Your invoice items have no invoice attribute, as the error says. > > By the way, although I'm not sure of what you're trying to achieve, let me > point out

Re: Integrity Error

2011-08-26 Thread Thomas Orozco
Your invoice items have no invoice attribute, as the error says. By the way, although I'm not sure of what you're trying to achieve, let me point out that there is not really a need for a sum field in your invoice as you can just sum all the invoice items' amount (and respect the DRY principle -

Re: Integrity Error with generic relation using ContentType

2011-06-15 Thread christian.posta
Well, there are some ways around it if you use dumpdata/loaddata statements. But for initial fixtures, it causes trouble. When the DB is created, django will dynamically try to populate the content-types table. But if you are already putting data into that table, the primary keys will clash. When

Re: Integrity Error with generic relation using ContentType

2011-06-14 Thread Amit Sethi
On Tue, Jun 14, 2011 at 8:00 PM, christian.posta wrote: > Yes, it is. Any reason why you want the content-types to be part of > your fixtures? Why not let django build that up by itself? > Well essentially it was just a dumpdata from earlier that is being used. But why

Re: Integrity Error with generic relation using ContentType

2011-06-14 Thread christian.posta
Yes, it is. Any reason why you want the content-types to be part of your fixtures? Why not let django build that up by itself? On Jun 14, 1:21 am, Amit Sethi wrote: > On Tue, Jun 14, 2011 at 1:41 AM, christian.posta > wrote: > > Are you

Re: Integrity Error with generic relation using ContentType

2011-06-14 Thread Amit Sethi
On Tue, Jun 14, 2011 at 1:41 AM, christian.posta wrote: > Are you using your own fixtures (like initial_data.json)? > Is it possible that in your initial_data.json ( or whatever fixture > you're using) that you're including entries into the content_types [..] Well i do

Re: Integrity Error with generic relation using ContentType

2011-06-13 Thread christian.posta
Are you using your own fixtures (like initial_data.json)? Is it possible that in your initial_data.json ( or whatever fixture you're using) that you're including entries into the content_types table? You should probably remove that from your fixtures and let django build the content types

Re: Integrity Error on chained FKs

2011-03-27 Thread shofty
Daniel, thanks for pointing that out, the amended code now does what it was supposed to do. makes perfect sense when you explained it. i already had the slug and user excluded, which is why it allowed me to add them but didn't validate them im guessing. chained fk's was down to the error

Re: Integrity Error on chained FKs

2011-03-27 Thread Daniel Roseman
On Sunday, March 27, 2011 9:41:53 AM UTC+1, shofty wrote: > > this is the view code... > > u = get_object_or_404(UserProfile, user=request.user) > if request.method == "POST": > # submitted the add venue form > venue_form = VenueForm(request.POST) >

Re: Integrity Error on chained FKs

2011-03-27 Thread shofty
been playing with this some more and i still can't work out what ive done to cause this issue. as i see it, when saving a Venue, the Survey model which is FK'd to the Venue is complaining that the user_id isn't set. However there is nothing being saved by the Survey model, so why is it even

Re: Integrity Error on chained FKs

2011-03-27 Thread shofty
this is the view code... u = get_object_or_404(UserProfile, user=request.user) if request.method == "POST": # submitted the add venue form venue_form = VenueForm(request.POST) venue_form.user = u venue_form.slug = slugify(request.POST['name']) if

Re: Integrity Error on chained FKs

2011-03-25 Thread gladys
The error you are getting has something to do with your user field in the Venue model, which based from your models cannot be null. How are you associating a user to it? On Mar 25, 7:45 pm, shofty wrote: > I've got the following models. > > class UserProfile(models.Model): >    

Re: Integrity Error with trying to save UserProfile automatically

2010-06-02 Thread kalinski
Hello again, well i am stupid: the code above works,null=True should work but when changin the model a simple "manage.py syncdb" is sometimes not enough as it does not alter created tables so i "manage.py reset" the whole thing and that's it... sorry for the spam kalinsko On Jun 2, 8:34 pm,

Re: Integrity error in get_or_create

2009-06-22 Thread Alessandro Ronchi
2009/6/21 Alessandro Ronchi > > it gets into the except and tries to open another User with the same id! > It seemed to be a very big int for uid that caused a truncation when saving into database. -- Alessandro Ronchi Skype: aronchi SOASI Soc.Coop. -

Re: Integrity error in get_or_create

2009-06-21 Thread Alessandro Ronchi
2009/6/21 Alessandro Ronchi > I have a very strange problem. > > With this function: > > def get_current(self): > > facebook = get_facebook_client() > user, created = self.get_or_create(id=int(facebook.uid)) > if created: > #

Re: Integrity error handling

2009-05-27 Thread orokusaki
In your form sub-class class you'll need to override the clean method to check for duplicate entries and raise a validation error if they exists: from somewhere import models from somewhere import forms class myForm(forms.ModelForm): some_unique_field = forms.CharField() class

Re: Integrity error handling

2009-05-21 Thread Bobby Roberts
any ideas? --~--~-~--~~~---~--~~ 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

Re: Integrity error with get_or_create()

2008-12-22 Thread Casey Deccio
I've looked into this further, and it looks like it's actually an issue with PostgreSQL, not django. The field I'm querying is of type inet, and I'm inputting an IPv6 address. However, it appears that in PostgreSQL (running version 8.3.5) IPv6 addresses only match a query when the string being

Re: Integrity Error (1062, "Duplicate entry '0' for key 1") ???

2008-09-14 Thread Brandon Taylor
Well, after validating, syncing, re-validating and re-syncing, I ended up just dropping the entire database and now it works fine. On Sep 14, 10:10 am, Brandon Taylor <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I'm using 1.0 Final, MySQL 5, and I'm getting this lovely error for > the first

Re: Integrity Error, regarding NULL values

2006-03-13 Thread Panos Laganakos
>From the http://code.djangoproject.com/wiki/NewbieMistakes Problem ¶ When you have a Field: current_zip = meta.IntegerField(maxlength=5,blank=True) django will create a not nullable field in the DB. However leaving the field blank (in admin/web) django will try and insert a NULL value in the

Re: Integrity Error, regarding NULL values

2006-03-13 Thread Panos Laganakos
Hey Tim, Yeah, I understand what you mean, but I thought that django used "" by default and not NULL. That's why I defined in my model to allow blank, and not include null=True. Part of the model is this: class Factor(meta.Model): 20 first_name = meta.CharField(maxlength=25)