Saturday, May 11, 2013

Re: Is unique_together case-insensitive ?

Got it
Thanks!


On Sat, May 11, 2013 at 1:42 PM, Joey Chang <changjian53@gmail.com> wrote:
You can'n change it via django directly. 
this link is django collation-settings notes.
and
this shows how to change the collation in mysql.



2013/5/11 Parin Porecha <parinporecha@gmail.com>
Yes, I forgot to mention
I am running Django 1.5, with database MySQL

So, how can I change the COLLATE pattern through Django's model fields ?
If not via Django, can you show me how to change it manually ?


On Sat, May 11, 2013 at 1:19 PM, Joey Chang <changjian53@gmail.com> wrote:
What's your database engine?
As i know, if your  database engine was  mysql, and the database's COLLATE pattern name ends with "_ci" which means case-insensitive. you should got that result. 
You can change the COLLATE pattern to the name which ends with "_cs" or "_bin".
Wish it's useful to you



2013/5/11 Parin Porecha <parinporecha@gmail.com>
UPDATE:

On changing the user, it gets saved successfully.
So, the problem is with the object.name

I want to save both the objects. How can I do so ?


On Sat, May 11, 2013 at 12:48 PM, Parin Porecha <parinporecha@gmail.com> wrote:
Hi,

This is my model -

class Tag(models.Model):
    user = models.ForeignKey(get_user_model())
    name = models.CharField(max_length = 300)
    color = models.CharField(max_length = 10)
    icon = models.CharField(max_length = 50)
    
    class Meta:
        unique_together = ("user", "name")
    
    def __unicode__(self, ):
        return self.name

The problem I am facing is -
I made 2 Tag objects =
1) Tag(user = jon, name = 'man')
2) Tag(user = jon, name = 'Man')

The first gets saved, but while saving the second, I am getting the error -
IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")

I deleted the database, created it again and ran 'syncdb'. Still, I am getting the same error. Is this because of unique_together ?
How can I bypass this ?

Thanks,
Parin


--
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate