Re: SyncDB w/ MySQL - Has anyone seen an error like this?

2013-05-11 Thread Kurtis
To try and find more information, I erased the Django-created tables and 
re-ran syncdb again. This time, I turned verbosity on to 3 and piped all of 
my stdout to a text file. I actually did this first. However, here's the 
contents of the first one which includes everything up to the point of 
failure.

Creating tables ...
Processing auth.Permission model
Creating table auth_permission
Processing auth.Group_permissions model
Creating table auth_group_permissions
Processing auth.Group model
Creating table auth_group
Processing contenttypes.ContentType model
Creating table django_content_type
Processing sessions.Session model
Creating table django_session
Processing sites.Site model
Creating table django_site
Processing admin.LogEntry model
Creating table django_admin_log

Note that I do have a custom UserModel, UserManager, and related Admin 
stuff based off of the docs. Could this be related to the problem? I 
removed a "db_index=True" option I had set on the User's email address.

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




Re: SyncDB w/ MySQL - Has anyone seen an error like this?

2013-05-11 Thread Kurtis
I should mention that I *did* convert all of my existing tables to InnoDB 
which hasn't helped at all. I don't have any weird configuration in my 
settings.py dealing with the database. As far as I can tell, all new tables 
created by syncdb are also InnoDB.

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




SyncDB w/ MySQL - Has anyone seen an error like this?

2013-05-11 Thread Kurtis
When running syncdb, I am getting an unusual error. I'm using Django 1.5.1 
and a relatively recent version of MariaDB on Arch. I am using some 
pre-existing tables which I've built Models around. The error is:

*DatabaseError: (1005, "Can't create table '.#sql-1e51_2be' (errno: 150)")*

Running syncdb a second time seems to finish out the process without error.

Searching around hasn't really helped tremendously. At least, I'm not 
looking in the right place.

At first glance, I thought that maybe this was some weird table name. After 
some further thinking, does this hash symbol represent something in MySQL 
land? Perhaps an index? Perhaps literally implemented as a hash table? haha

I tried to debug it. I figured if I could get ahold of the SQL produced by 
syncdb and run it manually then the RDBMS might give me some more verbose 
output.

Unfortunately, I have my project broken up into quite a few modules (apps) 
and have no idea how the syncdb command goes about chaining the various 
"sqlall " dumps I can produce. I know with indexes in particular, 
order is important.

So, any clue as to what might be going on or how to dig in deeper? 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: HttpResponse.has_header

2013-05-11 Thread Larry Martell
On Sat, May 11, 2013 at 9:08 AM, Masklinn  wrote:
>
> On 2013-05-11, at 17:01 , Larry Martell wrote:
>
>> On Sat, May 11, 2013 at 8:23 AM, Masklinn  wrote:
>>> On 2013-05-11, at 15:57 , Larry Martell wrote:

 Yes, that is what I did. This is not in my urlconf. It's in a view
 function. I replaced:

 return direct_to_template(request, template)

 by:

 return TemplateView.as_view(template_name=template)

 Is that not correct?
>>>
>>> Indeed not, `TemplateView.as_view(template)` is roughly equivalent to
>>> `functools.partial(direct_to_template, template=template)`: it's only
>>> one half of the operation, which returns a callable replying to
>>> requests.
>>>
>>> You need something along the lines of 
>>> `TemplateView.as_view(template)(request)`
>>
>> I appreciate all the assistance. I tried that and got:
>>
>> TypeError: as_view() takes exactly 1 argument (2 given)
>>
>
> Oh yeah, you need to pass it as the keyword argument "template_name"
> sorry about that. Basically take your code and add "(request)" at the
> end.
>
> If the current request is a GET obviously.

Thanks. That got me further along. I don't understand that syntax
though. Never see that before.

But now I'm having a NoReverseMatch issue that I don't get in 1.4.
I'll have to dig into that on Monday.

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




Can I use Connector/Python instead of MySQLdb? And how?

2013-05-11 Thread icedream91
I am using Python 3.3.1 and Django 1.5.1. MySQLdb doesn't support Python 3, 
so I want to use Connector/Python instead. But I don't know how to do this.

Is it easy to do this? If it is, how can I do this?

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




Re: Trying to figure out ManyToManyField on a legacy database

2013-05-11 Thread brian
Thanks Kevin, that did the trick. 

This is going to be an interesting project. There are 3 different
database types with DJ's song info involved. Each DJ has their private
database. 

Can I have different models, and have a way to link the different DJ's
databases to the correct model for their database type?

Brian
 
On Sat, 2013-05-11 at 16:37 -0700, kevin wrote:
> Hi Brian,
> 
> It seems like you don't really have an Many To Many relationship
> between your "Song" and "Played" objects.  I can see how you would
> have multiple plays for one song, but considering that the Played
> model has a track_id, would you ever have multiple songs for a single
> Play?It appears that "track_id" is intended to be a foreign key
> into the Song table, so maybe you could consider using a ForeignKey
> field to refer to your Song through your Played object.  Django will
> automatically create 2-way references so you can get to your played
> objects from your song object::
> 
> 
> class Played(models.Model):
>   played_id = models.IntegerField(primary_key=True)
>   track = models.ForeignKey('Song')
>   date_played = models.DateTimeField()
>   played_by = models.CharField(max_length=255L)
>   played_by_me = models.IntegerField()
>   class Meta:
>db_table = 'played'
> 
> 
> 
> class Song(models.Model):
> 
>   id = models.IntegerField(primary_key=True)
>   title = models.CharField(max_length=255L, blank=True)
>   class Meta:
>   db_table = 'song'
> 
> 
> Then, you should be able to get all of the Plays for a particular
> song::  
> 
> 
> 
> 
> s = Song.objects.get(id=1229)
> s.title # should be OK still
> s.played_set.all() # should be a list of plays.



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




Re: Trying to figure out ManyToManyField on a legacy database

2013-05-11 Thread kevin
Hi Brian,

It seems like you don't really have an Many To Many relationship between 
your "Song" and "Played" objects.  I can see how you would have multiple 
plays for one song, but considering that the Played model has a track_id, 
would you ever have multiple songs for a single Play?It appears that 
"track_id" is intended to be a foreign key into the Song table, so maybe 
you could consider using a ForeignKey field to refer to your Song through 
your Played object.  Django will automatically create 2-way references so 
you can get to your played objects from your song object::

class Played(models.Model):
  played_id = models.IntegerField(primary_key=True)
  track = models.ForeignKey('Song')
  date_played = models.DateTimeField()
  played_by = models.CharField(max_length=255L)
  played_by_me = models.IntegerField()
  class Meta:
   db_table = 'played'

class Song(models.Model):
  id = models.IntegerField(primary_key=True)
  title = models.CharField(max_length=255L, blank=True)
  class Meta:
  db_table = 'song'

Then, you should be able to get all of the Plays for a particular song::  


s = Song.objects.get(id=1229)
s.title # should be OK still
s.played_set.all() # should be a list of plays.



On Saturday, May 11, 2013 5:33:46 PM UTC-5, Brian Millham wrote:
>
> Hi all,
> I'm just trying to learn Django. I have an existing site that I wrote in 
> PHP, and I'l considering converting it to Django,
>
> I have a legacy database that I don't want to make any changes to. I have 
> the basics working in Django, but am having a problem with a 
> ManyToManyField.
>
> Here are the 2 tables (simplified)
>
> class Played(models.Model):
>   played_id = models.IntegerField(primary_key=True)
>   track_id = models.IntegerField()
>   date_played = models.DateTimeField()
>   played_by = models.CharField(max_length=255L)
>   played_by_me = models.IntegerField()
>   class Meta:
>db_table = 'played'
>
> class Song(models.Model):
>   id = models.IntegerField(primary_key=True)
>   title = models.CharField(max_length=255L, blank=True)
>   #These are what I've tried for ManyToMany with the error
>   played = models.ManyToManyField(Played, db_column='id') # DatabaseError: 
> (1146, "Table 'ampache.song_played' doesn't exist")
>   played = models.ManyToManyField(Played, db_column='track_id') # 
> DatabaseError: (1146, "Table 'ampache.song_played' doesn't exist")
>   played = models.ManyToManyField(Played, db_table = 'played', 
> db_column='id') # DatabaseError: (1054, "Unknown column 'T2.song_id' in 
> 'where clause'")
>   played = models.ManyToManyField(Played, db_table = 'played', 
> db_column='track_id') # DatabaseError: (1054, "Unknown column 'T2.song_id' 
> in 'where  clause'")
>   played = models.ManyToManyField(Played, through = 'played', 
> db_column='id') # AttributeError: 'ManyToManyField' object has no attribute 
> '_m2m_reverse_name_cache'
>   class Meta:
>db_table = 'song'
>
> The code to produce the errors:
>
>> from djmusic.models import Song, Played
>> s = Song.objects.get(id=1229)
>> print s.title # Prints the title correctly
>> print s.played.all() # Generates one of the above errors
>>
>
> I know it's gotta be something simple I'm missing here. If I can get this 
> figured out, there's a good chance that I'll convert my old PHP based site 
> to Django. 
>
> Thanks all!
>  
>
>

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




Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-11 Thread Hu Shizhi
Thanks Raharu. It works.

Best,

Tian

On Saturday, May 11, 2013 10:12:37 PM UTC+8, Raharu Haruha wrote:
>
> there is no pattern named "index" (name="index") so, no reverse match
> also, if you planned to work with django in future, i suggest you to use 
> new-style url template tag like so:
>
> {% load url form future %}
> ...
> {% url 'index' %}
> ...
>
> On Saturday, May 11, 2013 5:14:02 AM UTC+4, Hu Shizhi wrote:
>>
>> My urls.py:
>>
>> from django.conf.urls import patterns, include, url
>> # from django.contrib.auth import login, logout   
>>
>>
>> # Uncomment the next two lines to enable the admin:   
>>
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>> # url(r'^$', 'patient.views.home', name='home'), 
>> 
>> url(r'^accounts/', include('registration.backends.default.urls')),
>> # url(r'^register/$', 'patient.views.register'), 
>> 
>> #   url(r'^login/$', 'login', name='login'), 
>> 
>> # url(r'^logout/$', 'logout'),   
>> 
>> # url(r'^patient/', include('patient.urls')), 
>>
>>
>> # Uncomment the admin/doc line below to enable admin documentation:   
>>
>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 
>> 
>>
>> # Uncomment the next line to enable the admin:   
>> 
>> url(r'^admin/', include(admin.site.urls)),
>> )
>>
>> On Friday, May 10, 2013 11:22:08 PM UTC+8, C. Kirby wrote:
>>>
>>> Do you have a urls.py file? To used the url tag with a name you need to 
>>> have a defined url with that name, example:
>>>
>>> urlpatterns = patterns('',
>>> url(r'^$', 'app.views.index', name="index"),
>>> )
>>>
>>> On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:

 Hi,

 I am new to Django and am using django-registration and followed the 
 quickstart.rst document and get the following. Could anyone kindly help?

 Thanks,

 Tian

 NoReverseMatch at /accounts/login/

 Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
 found.

 Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
 Version:1.4Exception Type:NoReverseMatchException Value:

 Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
 found.

 Exception 
 Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
  
 in render, line 424Python Executable:
 /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
 Path:

 ['/Users/apple/projects/misc/health',
  
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
  
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
  
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
  
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
  '/Users/apple/.virtualenvs/health/lib/python27.zip',
  '/Users/apple/.virtualenvs/health/lib/python2.7',
  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
  
 '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
  '/Users/apple/.virtualenvs/health/Extras/lib/python',
  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
  

Trying to figure out ManyToManyField on a legacy database

2013-05-11 Thread Brian Millham
Hi all,
I'm just trying to learn Django. I have an existing site that I wrote in 
PHP, and I'l considering converting it to Django,

I have a legacy database that I don't want to make any changes to. I have 
the basics working in Django, but am having a problem with a 
ManyToManyField.

Here are the 2 tables (simplified)

class Played(models.Model):
  played_id = models.IntegerField(primary_key=True)
  track_id = models.IntegerField()
  date_played = models.DateTimeField()
  played_by = models.CharField(max_length=255L)
  played_by_me = models.IntegerField()
  class Meta:
   db_table = 'played'

class Song(models.Model):
  id = models.IntegerField(primary_key=True)
  title = models.CharField(max_length=255L, blank=True)
  #These are what I've tried for ManyToMany with the error
  played = models.ManyToManyField(Played, db_column='id') # DatabaseError: 
(1146, "Table 'ampache.song_played' doesn't exist")
  played = models.ManyToManyField(Played, db_column='track_id') # 
DatabaseError: (1146, "Table 'ampache.song_played' doesn't exist")
  played = models.ManyToManyField(Played, db_table = 'played', 
db_column='id') # DatabaseError: (1054, "Unknown column 'T2.song_id' in 
'where clause'")
  played = models.ManyToManyField(Played, db_table = 'played', 
db_column='track_id') # DatabaseError: (1054, "Unknown column 'T2.song_id' 
in 'where  clause'")
  played = models.ManyToManyField(Played, through = 'played', 
db_column='id') # AttributeError: 'ManyToManyField' object has no attribute 
'_m2m_reverse_name_cache'
  class Meta:
   db_table = 'song'

The code to produce the errors:

> from djmusic.models import Song, Played
> s = Song.objects.get(id=1229)
> print s.title # Prints the title correctly
> print s.played.all() # Generates one of the above errors
>

I know it's gotta be something simple I'm missing here. If I can get this 
figured out, there's a good chance that I'll convert my old PHP based site 
to Django. 

Thanks all!
 

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




Re: form validation

2013-05-11 Thread Roberto López López

Problem solved with BaseInlineFormSet.clean() :-)




On 05/11/2013 06:56 PM, Roberto López López wrote:
>
> Hi everyone,
>
> I need to do some validation in my model. So far, I have been able to
> validate normal forms, but I want to validate forms with an inline, to
> ensure that at least one of those inlines match the requirement.
>
> My code:
>
> class PDMAdminForm(ModelForm):
> class Meta:
> model = PersonDepartmentMembership
>
> def clean(self):
> previous_leaders = []
> if self.instance:  # the instance is already on the db
> previous_leaders =
> self.instance.department.employee_memberships.filter(lead__exact=True)
> lead = self.cleaned_data['lead'] # access fields from the
> form itself
> # do some validations and eventually throw
> ValidationErrrors [...]
> return self.cleaned_data
>
> This works great for a single inline. But if I have several
> PersonDepartmentMembership instances to be created, I don't know how
> to check the value of those other (I just want to ensure that at least
> one fo them has lead==True).
>
> Does anyone know how to do this cross validation? Thank you very much
> for your suggestions.
>
> Regards,
>
> Roberto
>
>
> -- 
> 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?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+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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




form validation

2013-05-11 Thread Roberto López López

Hi everyone,

I need to do some validation in my model. So far, I have been able to
validate normal forms, but I want to validate forms with an inline, to
ensure that at least one of those inlines match the requirement.

My code:

class PDMAdminForm(ModelForm):
class Meta:
model = PersonDepartmentMembership

def clean(self):
previous_leaders = []
if self.instance:  # the instance is already on the db
previous_leaders =
self.instance.department.employee_memberships.filter(lead__exact=True)
lead = self.cleaned_data['lead'] # access fields from the
form itself
# do some validations and eventually throw ValidationErrrors
[...]
return self.cleaned_data

This works great for a single inline. But if I have several
PersonDepartmentMembership instances to be created, I don't know how to
check the value of those other (I just want to ensure that at least one
fo them has lead==True).

Does anyone know how to do this cross validation? Thank you very much
for your suggestions.

Regards,

Roberto


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




Re: HttpResponse.has_header

2013-05-11 Thread Masklinn

On 2013-05-11, at 17:01 , Larry Martell wrote:

> On Sat, May 11, 2013 at 8:23 AM, Masklinn  wrote:
>> On 2013-05-11, at 15:57 , Larry Martell wrote:
>>> 
>>> Yes, that is what I did. This is not in my urlconf. It's in a view
>>> function. I replaced:
>>> 
>>> return direct_to_template(request, template)
>>> 
>>> by:
>>> 
>>> return TemplateView.as_view(template_name=template)
>>> 
>>> Is that not correct?
>> 
>> Indeed not, `TemplateView.as_view(template)` is roughly equivalent to
>> `functools.partial(direct_to_template, template=template)`: it's only
>> one half of the operation, which returns a callable replying to
>> requests.
>> 
>> You need something along the lines of 
>> `TemplateView.as_view(template)(request)`
> 
> I appreciate all the assistance. I tried that and got:
> 
> TypeError: as_view() takes exactly 1 argument (2 given)
> 

Oh yeah, you need to pass it as the keyword argument "template_name"
sorry about that. Basically take your code and add "(request)" at the
end.

If the current request is a GET obviously.

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




Re: HttpResponse.has_header

2013-05-11 Thread Larry Martell
On Sat, May 11, 2013 at 8:23 AM, Masklinn  wrote:
> On 2013-05-11, at 15:57 , Larry Martell wrote:
>>
>> Yes, that is what I did. This is not in my urlconf. It's in a view
>> function. I replaced:
>>
>> return direct_to_template(request, template)
>>
>> by:
>>
>> return TemplateView.as_view(template_name=template)
>>
>> Is that not correct?
>
> Indeed not, `TemplateView.as_view(template)` is roughly equivalent to
> `functools.partial(direct_to_template, template=template)`: it's only
> one half of the operation, which returns a callable replying to
> requests.
>
> You need something along the lines of 
> `TemplateView.as_view(template)(request)`

I appreciate all the assistance. I tried that and got:

TypeError: as_view() takes exactly 1 argument (2 given)

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




Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-11 Thread Raharu Haruha
there is no pattern named "index" (name="index") so, no reverse match
also, if you planned to work with django in future, i suggest you to use 
new-style url template tag like so:

{% load url form future %}
...
{% url 'index' %}
...

On Saturday, May 11, 2013 5:14:02 AM UTC+4, Hu Shizhi wrote:
>
> My urls.py:
>
> from django.conf.urls import patterns, include, url
> # from django.contrib.auth import login, logout   
>
>
> # Uncomment the next two lines to enable the admin:   
>
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
> # url(r'^$', 'patient.views.home', name='home'),   
>   
> url(r'^accounts/', include('registration.backends.default.urls')),
> # url(r'^register/$', 'patient.views.register'),   
>   
> #   url(r'^login/$', 'login', name='login'),   
>   
> # url(r'^logout/$', 'logout'), 
>   
> # url(r'^patient/', include('patient.urls')), 
>
>
> # Uncomment the admin/doc line below to enable admin documentation:   
>
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),   
>   
>
> # Uncomment the next line to enable the admin: 
>   
> url(r'^admin/', include(admin.site.urls)),
> )
>
> On Friday, May 10, 2013 11:22:08 PM UTC+8, C. Kirby wrote:
>>
>> Do you have a urls.py file? To used the url tag with a name you need to 
>> have a defined url with that name, example:
>>
>> urlpatterns = patterns('',
>> url(r'^$', 'app.views.index', name="index"),
>> )
>>
>> On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:
>>>
>>> Hi,
>>>
>>> I am new to Django and am using django-registration and followed the 
>>> quickstart.rst document and get the following. Could anyone kindly help?
>>>
>>> Thanks,
>>>
>>> Tian
>>>
>>> NoReverseMatch at /accounts/login/
>>>
>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>> found.
>>>
>>> Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
>>> Version:1.4Exception Type:NoReverseMatchException Value:
>>>
>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>> found.
>>>
>>> Exception 
>>> Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
>>>  
>>> in render, line 424Python Executable:
>>> /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
>>> Path:
>>>
>>> ['/Users/apple/projects/misc/health',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
>>>  '/Users/apple/.virtualenvs/health/lib/python27.zip',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
>>>  '/Users/apple/.virtualenvs/health/Extras/lib/python',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
>>>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>>  
>>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>>  
>>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>>  
>>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>>  
>>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/PIL']
>>>
>>> Server time:Fri, 10 May 2013 22:29:17 +0800
>>> Error during template rendering
>>>
>>> In template 
>>> 

Re: Accessing django development server using internet

2013-05-11 Thread phil...@bailey.st
On 07/05/13 17:38, Kakar wrote:
> I have my project in my pc, and on python manage.py runserver, i can view it 
> on my browser. But how to view from other computer or on the internet and not 
> locally?... How to make my pc a server to view it from over the internet? Plz 
> help me guyz!
> 

I Kakar,

you can try www.heroku.com to deploy publicly your sample code.

Best,
Phillip



-- 
www.bailey.st

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




Invalid block tag with Inclusion Tag

2013-05-11 Thread neil
I am attempting to create a fairly straightforward inclusion tag out of 
nothing more than a hardcoded dictionary of keywords. My app is set up like 
this:

*apps*
*  keywords*
*templatetags*
*__init__.py*
*popular_keyword_tags.py*
*__init__.py*
*  __init__.py*

I have included* "apps.keywords"* in settings.py.

The module file *popular_keyword_tags.py* looks like this:

*register = template.Library()*
*
*
*@register.inclusion_tag('keywords/popular_keywords.html')*
*def show_popular_keywords():*
*popular_keyword_dict = dict()*
*...*
*return {'popular_keywords': popular_keyword_dict}*
*
*
*
*
*
*
In the template where I want to use the tag, I have this:

*{% load pages_tags mezzanine_tags i18n future staticfiles 
popular_keyword_tags %}*
*
*
*
*
Then finally I use the tag like this:
*
*
*{%  popular_keywords  %}
*
*
*
*
*
I feel like I have set everything up correctly, but I can't shake this*"Invalid 
block tag: 'popular_keywords'" 
*error.

Any help you can provide is appreciated. Let me know if I need to provide 
any more information.

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




Re: HttpResponse.has_header

2013-05-11 Thread Masklinn
On 2013-05-11, at 15:57 , Larry Martell wrote:
> 
> Yes, that is what I did. This is not in my urlconf. It's in a view
> function. I replaced:
> 
> return direct_to_template(request, template)
> 
> by:
> 
> return TemplateView.as_view(template_name=template)
> 
> Is that not correct?

Indeed not, `TemplateView.as_view(template)` is roughly equivalent to
`functools.partial(direct_to_template, template=template)`: it's only
one half of the operation, which returns a callable replying to
requests.

You need something along the lines of `TemplateView.as_view(template)(request)`

> Should I not be using as_view? I just tried using
> TemplateView(template_name=template) and I got the same error.

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




Re: HttpResponse.has_header

2013-05-11 Thread Larry Martell
On Sat, May 11, 2013 at 7:30 AM, Masklinn  wrote:
> On 2013-05-11, at 15:08 , Larry Martell wrote:
>> On Fri, May 10, 2013 at 2:13 PM, Larry Martell  
>> wrote:
>>> On Fri, May 10, 2013 at 9:37 AM, Larry Martell  
>>> wrote:
 On Fri, May 10, 2013 at 8:55 AM, Tom Evans  
 wrote:
> On Fri, May 10, 2013 at 2:52 PM, Larry Martell  
> wrote:
>> Just upgraded to 1.5 and my app is failing with:
>>
>> Internal Server Error:
>> Traceback (most recent call last):
>> File "/Library/Python/2.7/site-packages/django/core/handlers/base.py",
>> line 187, in get_response
>> response = middleware_method(request, response)
>>   File 
>> "/Library/Python/2.7/site-packages/django/contrib/sessions/middleware.py",
>> line 26, in process_response
>> patch_vary_headers(response, ('Cookie',))
>>   File "/Library/Python/2.7/site-packages/django/utils/cache.py",
>> line 142, in patch_vary_headers
>> if response.has_header('Vary'):
>> [error] AttributeError: 'function' object has no attribute 'has_header'
>>
>> My code that is triggering this:
>>
>> if report_response.has_header('Content-disposition'):
>>
>> I didn't see anything in the docs that said this method was being
>> removed from the HttpResponse class.
>>
>
> It hasn't. If you look at the exception message closely, you will see
> that it does not say "HttpResponse object has no attribute ...", it
> says "function object has no attribute ...". Somehow, this middleware
> is receiving a function instead of a response object.
>
>> Anyone know how I can fix this so I can use 1.5?
>>
>
> The full stack trace may explain more, but then again maybe not - the
> exception happens in middleware processing, but the error is returning
> a function instead of a HttpResponse object in the content generation
> phase (ie in the view). You will probably need to look closely at each
> function the request passes through on this particular request, and
> work out where the bogus return value is coming from.

 That is the full stack trace. I have just one piece of middleware:

 import re
 class LastSiteUrl(object):

def is_admin_url(self, url):
if re.search('^(http:\/\/.*){0,1}\/admin\/', url) is None: 
 return(False)
else: return(True)

def process_request(self, request):
if self.is_admin_url(request.path) and \
not self.is_admin_url(request.META['HTTP_REFERER']):
request.session['last_site_url'] = request.META['HTTP_REFERER']

 I don't see how that could be causing this. What changed in 1.5 to
 break this? In 1.4 I do not get this error with the same middleware.
>>>
>>> I traced it all through base.py and the issue seems to be that my
>>> views don't return a HttpResponse object. I have to go back to 1.4 and
>>> my old code and see what it's returning there (I made a lot of changes
>>> for direct_to_template and redirect_to). I wouldn't think an upgrade
>>> would require so many changes :-(
>>
>> So here's the problem. I replaced direct_to_template with
>> TemplateView.as_view (as I read at
>> https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/)
>> but direct_to_template returned a HttpResponse object and
>> TemplateView.as_view does not.
>
> as_view itself does not (and should not), since its job is to return a
> view callable which will reply to requests.
>
> TemplateView most definitely returns an HttpResponse though. More
> precisely it returns a TemplateResponse which extends SimpleTemplateResponse
> which extends HttpResponse:
>
> as_view[0] returns a ``view`` function[1] which dispatches the request
> to a CBV method based on the request's HTTP method[2]. That is
> TemplateView.get[3] which calls render_to_response on the
> TemplateResponseMixin[4]. Said render_to_response returns a new instance
> of self.response_class[5], which defaults to TemplateResponse[6] which
> as already noted is a subclass of HttpResponse through
> SimpleTemplateResponse[7].
>
> Are you sure you're using TemplateView correctly? Could you post your
> urlconf? If you got a function is it possible that you replaced
>
> (pattern, direct_to_template, {'template': template_name})
>
> by
>
> (pattern, TemplateView.as_view, {'template': template_name})
>
> and thus got the ``view`` function[1] as a "response"?

Yes, that is what I did. This is not in my urlconf. It's in a view
function. I replaced:

return direct_to_template(request, template)

by:

return TemplateView.as_view(template_name=template)

Is that not correct? Should I not be using as_view? I just tried using
TemplateView(template_name=template) and I got the same error.

>
>> It then blows up at:
>>
>>  

Re: HttpResponse.has_header

2013-05-11 Thread Masklinn
On 2013-05-11, at 15:08 , Larry Martell wrote:
> On Fri, May 10, 2013 at 2:13 PM, Larry Martell  
> wrote:
>> On Fri, May 10, 2013 at 9:37 AM, Larry Martell  
>> wrote:
>>> On Fri, May 10, 2013 at 8:55 AM, Tom Evans  wrote:
 On Fri, May 10, 2013 at 2:52 PM, Larry Martell  
 wrote:
> Just upgraded to 1.5 and my app is failing with:
> 
> Internal Server Error:
> Traceback (most recent call last):
> File "/Library/Python/2.7/site-packages/django/core/handlers/base.py",
> line 187, in get_response
> response = middleware_method(request, response)
>   File 
> "/Library/Python/2.7/site-packages/django/contrib/sessions/middleware.py",
> line 26, in process_response
> patch_vary_headers(response, ('Cookie',))
>   File "/Library/Python/2.7/site-packages/django/utils/cache.py",
> line 142, in patch_vary_headers
> if response.has_header('Vary'):
> [error] AttributeError: 'function' object has no attribute 'has_header'
> 
> My code that is triggering this:
> 
> if report_response.has_header('Content-disposition'):
> 
> I didn't see anything in the docs that said this method was being
> removed from the HttpResponse class.
> 
 
 It hasn't. If you look at the exception message closely, you will see
 that it does not say "HttpResponse object has no attribute ...", it
 says "function object has no attribute ...". Somehow, this middleware
 is receiving a function instead of a response object.
 
> Anyone know how I can fix this so I can use 1.5?
> 
 
 The full stack trace may explain more, but then again maybe not - the
 exception happens in middleware processing, but the error is returning
 a function instead of a HttpResponse object in the content generation
 phase (ie in the view). You will probably need to look closely at each
 function the request passes through on this particular request, and
 work out where the bogus return value is coming from.
>>> 
>>> That is the full stack trace. I have just one piece of middleware:
>>> 
>>> import re
>>> class LastSiteUrl(object):
>>> 
>>>def is_admin_url(self, url):
>>>if re.search('^(http:\/\/.*){0,1}\/admin\/', url) is None: 
>>> return(False)
>>>else: return(True)
>>> 
>>>def process_request(self, request):
>>>if self.is_admin_url(request.path) and \
>>>not self.is_admin_url(request.META['HTTP_REFERER']):
>>>request.session['last_site_url'] = request.META['HTTP_REFERER']
>>> 
>>> I don't see how that could be causing this. What changed in 1.5 to
>>> break this? In 1.4 I do not get this error with the same middleware.
>> 
>> I traced it all through base.py and the issue seems to be that my
>> views don't return a HttpResponse object. I have to go back to 1.4 and
>> my old code and see what it's returning there (I made a lot of changes
>> for direct_to_template and redirect_to). I wouldn't think an upgrade
>> would require so many changes :-(
> 
> So here's the problem. I replaced direct_to_template with
> TemplateView.as_view (as I read at
> https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/)
> but direct_to_template returned a HttpResponse object and
> TemplateView.as_view does not.

as_view itself does not (and should not), since its job is to return a
view callable which will reply to requests.

TemplateView most definitely returns an HttpResponse though. More
precisely it returns a TemplateResponse which extends SimpleTemplateResponse
which extends HttpResponse:

as_view[0] returns a ``view`` function[1] which dispatches the request
to a CBV method based on the request's HTTP method[2]. That is
TemplateView.get[3] which calls render_to_response on the
TemplateResponseMixin[4]. Said render_to_response returns a new instance
of self.response_class[5], which defaults to TemplateResponse[6] which
as already noted is a subclass of HttpResponse through
SimpleTemplateResponse[7].

Are you sure you're using TemplateView correctly? Could you post your
urlconf? If you got a function is it possible that you replaced

(pattern, direct_to_template, {'template': template_name}) 

by

(pattern, TemplateView.as_view, {'template': template_name})

and thus got the ``view`` function[1] as a "response"?

> It then blows up at:
> 
>  File "/Library/Python/2.7/site-packages/django/utils/cache.py", line
> 142, in patch_vary_headers
>if response.has_header('Vary'):
> AttributeError: 'function' object has no attribute 'has_header'
> 
> Surely others must have changed direct_to_template to TemplateView.
> How do I get around this?

[0] 
https://github.com/django/django/blob/master/django/views/generic/base.py#L46
[1] 
https://github.com/django/django/blob/master/django/views/generic/base.py#L61
[2] 

Re: HttpResponse.has_header

2013-05-11 Thread Larry Martell
On Fri, May 10, 2013 at 2:13 PM, Larry Martell  wrote:
> On Fri, May 10, 2013 at 9:37 AM, Larry Martell  
> wrote:
>> On Fri, May 10, 2013 at 8:55 AM, Tom Evans  wrote:
>>> On Fri, May 10, 2013 at 2:52 PM, Larry Martell  
>>> wrote:
 Just upgraded to 1.5 and my app is failing with:

 Internal Server Error:
 Traceback (most recent call last):
 File "/Library/Python/2.7/site-packages/django/core/handlers/base.py",
 line 187, in get_response
  response = middleware_method(request, response)
File 
 "/Library/Python/2.7/site-packages/django/contrib/sessions/middleware.py",
 line 26, in process_response
  patch_vary_headers(response, ('Cookie',))
File "/Library/Python/2.7/site-packages/django/utils/cache.py",
 line 142, in patch_vary_headers
  if response.has_header('Vary'):
  [error] AttributeError: 'function' object has no attribute 'has_header'

 My code that is triggering this:

 if report_response.has_header('Content-disposition'):

 I didn't see anything in the docs that said this method was being
 removed from the HttpResponse class.

>>>
>>> It hasn't. If you look at the exception message closely, you will see
>>> that it does not say "HttpResponse object has no attribute ...", it
>>> says "function object has no attribute ...". Somehow, this middleware
>>> is receiving a function instead of a response object.
>>>
 Anyone know how I can fix this so I can use 1.5?

>>>
>>> The full stack trace may explain more, but then again maybe not - the
>>> exception happens in middleware processing, but the error is returning
>>> a function instead of a HttpResponse object in the content generation
>>> phase (ie in the view). You will probably need to look closely at each
>>> function the request passes through on this particular request, and
>>> work out where the bogus return value is coming from.
>>
>> That is the full stack trace. I have just one piece of middleware:
>>
>> import re
>> class LastSiteUrl(object):
>>
>> def is_admin_url(self, url):
>> if re.search('^(http:\/\/.*){0,1}\/admin\/', url) is None: 
>> return(False)
>> else: return(True)
>>
>> def process_request(self, request):
>> if self.is_admin_url(request.path) and \
>> not self.is_admin_url(request.META['HTTP_REFERER']):
>> request.session['last_site_url'] = request.META['HTTP_REFERER']
>>
>> I don't see how that could be causing this. What changed in 1.5 to
>> break this? In 1.4 I do not get this error with the same middleware.
>
> I traced it all through base.py and the issue seems to be that my
> views don't return a HttpResponse object. I have to go back to 1.4 and
> my old code and see what it's returning there (I made a lot of changes
> for direct_to_template and redirect_to). I wouldn't think an upgrade
> would require so many changes :-(

So here's the problem. I replaced direct_to_template with
TemplateView.as_view (as I read at
https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/)
but direct_to_template returned a HttpResponse object and
TemplateView.as_view does not. It then blows up at:

  File "/Library/Python/2.7/site-packages/django/utils/cache.py", line
142, in patch_vary_headers
if response.has_header('Vary'):
AttributeError: 'function' object has no attribute 'has_header'

Surely others must have changed direct_to_template to TemplateView.
How do I get around this?

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




Re: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
Got it
Thanks!


On Sat, May 11, 2013 at 1:42 PM, Joey Chang  wrote:

> You can'n change it via django directly.
> https://docs.djangoproject.com/en/1.5/ref/databases/#collation-settings
> this link is django collation-settings notes.
> and
> http://dev.mysql.com/doc/refman/5.0/en/charset-column.html
>  this shows how to change the collation in mysql.
>
>
>
> 2013/5/11 Parin Porecha 
>
>> 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 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 
>>>
  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  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+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?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+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?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+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?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+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?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+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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is unique_together case-insensitive ?

2013-05-11 Thread Joey Chang
You can'n change it via django directly.
https://docs.djangoproject.com/en/1.5/ref/databases/#collation-settings
this link is django collation-settings notes.
and
http://dev.mysql.com/doc/refman/5.0/en/charset-column.html
this shows how to change the collation in mysql.



2013/5/11 Parin Porecha 

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




Re: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
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  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 
>
>>  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 
>> 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+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?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+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?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+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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is unique_together case-insensitive ?

2013-05-11 Thread Joey Chang
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 

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




Re: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
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 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+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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
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+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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.