Re: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?
I admit it is vexing that Django overrides what you have specified in the settings file in this case, but it doesn't seem to be hard to override. I simply added "settings.DEBUG = True" to the beginning of the "setUp" function for the test class and that seems to do the trick. Btw, I see tracebacks in the console when a page has errors while running tests, don't you? Maybe that's a feature of django-nose, which I am using, I don't know. On Tuesday, January 29, 2013 2:39:58 AM UTC-6, Alessandro Pelliciari wrote: > When i run my selenium tests (LiveServerTestCase type) and i have some > error in my code (not in the test, i mean in the code executed, like > the homepage view i reach with selenium) i get the 500 public template > (that usually i get when i have DEBUG = False) even if i have: > > DEBUG = True > INTERNAL_IPS = ('127.0.0.1',) > > > I'm stuck with that and i can't see why my test failed (because in the > public 500 ofc i don't show the exceptions). > -- 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: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?
pdb works but i don't want to set pdb every time i have a problem, i want to know the exception/source first this import class BaseTestCase(LiveServerTestCase): def setUp(self): setattr(settings, 'DEBUG', True) *doesn't work for me* :( Il giorno sabato 9 febbraio 2013 20:38:58 UTC+1, Ron Elliott ha scritto: > > > > On Tuesday, January 29, 2013 2:39:58 AM UTC-6, Alessandro Pelliciari wrote: >> >> Hi, I'm writing some tests with Selenium. >> >> When i run my selenium tests (LiveServerTestCase type) and i have some >> error in my code (not in the test, i mean in the code executed, like the >> homepage view i reach with selenium) i get the 500 public template (that >> usually i get when i have DEBUG = False) even if i have: >> >> DEBUG = True >> INTERNAL_IPS = ('127.0.0.1',) >> >> I'm stuck with that and i can't see why my test failed (because in the >> public 500 ofc i don't show the exceptions). >> >> When i run the runserver it works perfectly (i get the tracebacks). >> >> I've checked the ip from request.META when i run it in a selenium test >> and it's the localhost, not other network IP. >> >> *Why does it behave like that? Where can i look to resolve?* >> > this work: > > class BaseTestCase(LiveServerTestCase): > > def setUp(self): > setattr(settings, 'DEBUG', True) > > now make all of your test cases inherit from that test case > -- 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: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?
On Tuesday, January 29, 2013 2:39:58 AM UTC-6, Alessandro Pelliciari wrote: > > Hi, I'm writing some tests with Selenium. > > When i run my selenium tests (LiveServerTestCase type) and i have some > error in my code (not in the test, i mean in the code executed, like the > homepage view i reach with selenium) i get the 500 public template (that > usually i get when i have DEBUG = False) even if i have: > > DEBUG = True > INTERNAL_IPS = ('127.0.0.1',) > > I'm stuck with that and i can't see why my test failed (because in the > public 500 ofc i don't show the exceptions). > > When i run the runserver it works perfectly (i get the tracebacks). > > I've checked the ip from request.META when i run it in a selenium test and > it's the localhost, not other network IP. > > *Why does it behave like that? Where can i look to resolve?* > this work: class BaseTestCase(LiveServerTestCase): def setUp(self): setattr(settings, 'DEBUG', True) now make all of your test cases inherit from that test case -- 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: How do I get the integer of a decimal string?
Thank you On Saturday, February 9, 2013 12:32:38 PM UTC-5, Brad Pitcher wrote: > > Convert it to float first: > int(float("14.00")) > > On Sat, 2013-02-09 at 09:27 -0800, frocco wrote: > > Hello, > > > > > > I am reading a cdv file and one col has the value of "14.00" > > I want to get the integer value if 14 > > I tried int("14.00") > > > > > > Thanks in advance > > > > -- > > 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...@googlegroups.com . > > To post to this group, send email to > > django...@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: Doubt in urls.py filter
Thanks Babatunde, I was aware of your solution. I am just curious if it is possible to make it just in the urls.py. Anyone? Em 09/02/2013 13:20, "Babatunde Akinyanmi" escreveu: > >The problem I have is that I want to use a view (rather not modifing it) > to show all person in a group. > > And if it's that you don't want to touch your view code, I'm not sure > you'll be able to do what you seek but I'll love also to know if it's > achievablebut I'm a noob anyway. > > Sent from my Windows Phone > -- > From: Thiago Carvalho D' Ávila > Sent: 2/9/2013 12:23 PM > To: Django Users > Subject: Doubt in urls.py filter > > Hello Guys, > > The problem I have is that I want to use a view (rather not modifing it) > to show all person in a group. > The problem is I don't know how to use the pk in the regex to filter in > the same line... > > I wanted something like: > > url(r'^groups/(?P\d+)/$', > login_required(MyListView.as_view(model=Person, > queryset=Person.objects.filter(groups__id=pk))), name='person_group_list'), > > With this I get: > NameError at /clientes/ > > name 'pk' is not defined > > Any hint? > > -- > 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: How do I get the integer of a decimal string?
Convert it to float first: int(float("14.00")) On Sat, 2013-02-09 at 09:27 -0800, frocco wrote: > Hello, > > > I am reading a cdv file and one col has the value of "14.00" > I want to get the integer value if 14 > I tried int("14.00") > > > Thanks in advance > > -- > 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.
How do I get the integer of a decimal string?
Hello, I am reading a cdv file and one col has the value of "14.00" I want to get the integer value if 14 I tried int("14.00") Thanks in advance -- 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: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?
Have you tried adding a: import pdb; pdb.set_trace() in the view to debug that way? On Jan 30, 2013 12:31 AM, "Alessandro Pelliciari" wrote: > Thanks for the answer! > > Because i'm developing and integrating some flow (social registration etc) > through tests. > > So, instead of creating every time a new user, creating a new social > association, and then after every try delete them from the database, the > test does it from me. > > So, its like a kind of dirty TDD with functional (selenium because i have > facebook login for example) testing. > > > Anyway i think i can resolve with the 500 response logging the error to > the console, but it's my first project in Django (and python) so i can't > understand completely the way to logging at this moment. > > > Alessandro > > > Il giorno mercoledì 30 gennaio 2013 03:18:46 UTC+1, Ramiro Morales ha > scritto: >> >> Ramiro Morales >> On Jan 29, 2013 12:33 PM, "Alessandro Pelliciari" >> wrote: >> > >> > thanks for the link! >> > >> > So Isn't there a way to set DEBUG=True in tests? >> >> No. There isn't (at least with the built-in testing toolbox). >> >> Now, I'm trying to understand why do you rely in the debugging 500 >> response contents on your tests. Do you screen scrap it to extract >> information about the origin of the failure? >> > -- > 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: Pattern for Ajax Forms using Django ModelForm and Class Based Views.
I might be worth checking out some sort of API library, like https://github.com/orokusaki/django-jsonrpc-2-0, which will allow you to perform whatever business logic you need to, and then simply return something like {"success": True, "errors": errors_list} - your templates and ordinary views could be leaner, if you A) separate your AJAX functionality from your non-AJAX views, and B) create a central client-side template (e.g., https://github.com/janl/mustache.js/) for rendering the contents of your model. On Friday, February 8, 2013 7:38:18 PM UTC-5, Kelly Nicholes wrote: > > What's the best practice for this? In my function based views, I'd check > if the form is_ajax() and if so, validate the form, render_to_string it to > a form template, and return that in a json dump along with a status code. > Then I check the status code to see if there are errors. If so, I close > the modal that the form is in, notify the user of successful addition, and > move on. If there are errors, I replace the form's HTML in the modal with > the new HTML that contains the form with error messages. This sucks > because I have to do this for every form and for every view that I have. -- 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: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?
I'm struggling with the same problem. It's pretty annoying that you can't run a LiveServerTestCase with debug=True. It makes it overly hard to do TDD at the beginning of a project, because you need to customise logging behaviour to get any kind of debugging working... hp (http://www.tdd-django-tutorial.com/) On Wednesday, January 30, 2013 8:30:33 AM UTC, Alessandro Pelliciari wrote: > > Thanks for the answer! > > Because i'm developing and integrating some flow (social registration etc) > through tests. > > So, instead of creating every time a new user, creating a new social > association, and then after every try delete them from the database, the > test does it from me. > > So, its like a kind of dirty TDD with functional (selenium because i have > facebook login for example) testing. > > > Anyway i think i can resolve with the 500 response logging the error to > the console, but it's my first project in Django (and python) so i can't > understand completely the way to logging at this moment. > > > Alessandro > > > Il giorno mercoledì 30 gennaio 2013 03:18:46 UTC+1, Ramiro Morales ha > scritto: >> >> Ramiro Morales >> On Jan 29, 2013 12:33 PM, "Alessandro Pelliciari" >> wrote: >> > >> > thanks for the link! >> > >> > So Isn't there a way to set DEBUG=True in tests? >> >> No. There isn't (at least with the built-in testing toolbox). >> >> Now, I'm trying to understand why do you rely in the debugging 500 >> response contents on your tests. Do you screen scrap it to extract >> information about the origin of the failure? >> > -- 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: Doubt in urls.py filter
>The problem I have is that I want to use a view (rather not modifing it) to show all person in a group. And if it's that you don't want to touch your view code, I'm not sure you'll be able to do what you seek but I'll love also to know if it's achievablebut I'm a noob anyway. Sent from my Windows Phone -- From: Thiago Carvalho D' Ávila Sent: 2/9/2013 12:23 PM To: Django Users Subject: Doubt in urls.py filter Hello Guys, The problem I have is that I want to use a view (rather not modifing it) to show all person in a group. The problem is I don't know how to use the pk in the regex to filter in the same line... I wanted something like: url(r'^groups/(?P\d+)/$', login_required(MyListView.as_view(model=Person, queryset=Person.objects.filter(groups__id=pk))), name='person_group_list'), With this I get: NameError at /clientes/ name 'pk' is not defined Any hint? -- 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: Doubt in urls.py filter
Hi Thiago, I have believe MyListView is a subclass of ListView. The cleaner way to do what you are trying to achieve will be to override the get_queryset() method. The code you gave is not working because pk will not be available when python starts to evaluate your urls.py file. pk becomes 'alive' when the regexp is evaluated. You can have something like this: url(r'^groups/(?P\d+)/$', login_required(MyListView.as_view(model=Person, )), name='person_group_list'), and then override get_queryset: def get_queryset(self): queryset = super(MyListView, self).get_queryset() pk = self.kwargs.get('pk') return queryset.filter(groups__id=pk) Sent from my Windows Phone -- From: Thiago Carvalho D' Ávila Sent: 2/9/2013 12:23 PM To: Django Users Subject: Doubt in urls.py filter Hello Guys, The problem I have is that I want to use a view (rather not modifing it) to show all person in a group. The problem is I don't know how to use the pk in the regex to filter in the same line... I wanted something like: url(r'^groups/(?P\d+)/$', login_required(MyListView.as_view(model=Person, queryset=Person.objects.filter(groups__id=pk))), name='person_group_list'), With this I get: NameError at /clientes/ name 'pk' is not defined Any hint? -- 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.
Doubt in urls.py filter
Hello Guys, The problem I have is that I want to use a view (rather not modifing it) to show all person in a group. The problem is I don't know how to use the pk in the regex to filter in the same line... I wanted something like: url(r'^groups/(?P\d+)/$', login_required(MyListView.as_view(model=Person, queryset=Person.objects.filter(groups__id=pk))), name='person_group_list'), With this I get: NameError at /clientes/ name 'pk' is not defined Any hint? -- 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: Replacing a model instance's __dict__
Tom, I suspect that there man be problematic, perhaps dependent on python version, because the __dict__ attribute itself is a slot (it couldn't, for example, be in the __dict__). Some slots may not accept assignment after creation, and the __dict__ object may not be an ordinary dict(). Separately, if I'm understanding correctly, there is a local database with a copy of the information. Unless you've done something special with the local model definitions, the id field will be problematic. I think that you're stuck with a for loop over synched_contact.items(), where you can filter keys that shouldn't be saved. You can also then uses setattr(self, key, value) instead of accessing self.__dict__, leaving you the flexibility for some of these attributes to be properties, if that turns out to be useful. Bill On Fri, Feb 8, 2013 at 12:50 PM, Tom Evans wrote: > Hi all > > I have a curious problem with a complex data replication issue. > > Basically, we use SalesForce as a CRM system. We also have a bunch of > users who aren't allowed a SF license due to cost reasons, and they > interact with SF via our own Django website that communicates to SF > via an API. > > With this API, we can CRUD all salesforce objects. We can also fetch > all changes since (specific time), so we maintain a local copy of all > our SF data in django models, synchronizing changes every 10 minutes > throughout the day. This actually works quite well! > > The problem comes with using django idioms like get_or_create(), when > an object is created directly on SF in the period since the last > synchronization. In this example, we want to get_or_create a Contact > with a specific email address. There is no Contact locally with the > specified email address, so get_or_create tries to create a new one. > > Using the API, this issues the appropriate query to SF, but since the > Contact already exists on SF, an exception is raised. > > get_or_create(), create() all work via save(), so my idea is to catch > this specific error in save, re-synchronise the database against the > remote end, pull the freshly synced record out of the database, and > replace self.__dict__ with new_item.__dict__, looking something like > this: > > def save(self, *args, **kwargs): > try: > super(Contact, self).save(*args, **kwargs) > except ValueError, e: > if 'Contact already exists' in unicode(e): > # Synchronize Contact objects with SF > run_log = SyncRunLog(start_time=datetime.now()) > run_log.save() > Contact.update(run_log) > # The contact should now be available locally > try: > synched_contact = Contact.objects.get(email=self.email) > self.__dict__ = synched_contact.__dict__ > except Contact.DoesNotExist: > # Still not there, raise a new ValueError > raise ValueError( > 'Failed to find contact %s after resyncing ' > 'Contact following this error: %s' > % (self.email, unicode(e))) > else: > raise e > > Is there an obvious issue with doing this? Can I simply replace > self.__dict__ like that without bad consequences? > > Cheers > > Tom > > -- > 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: How to create a Django Group in case of multiple databases.
It is wrong. As Tom pointed out, you must use: def save(self, *args, **kwargs): And then, wherever you call the super class save method, use: super(ModelName, self).save(*args, **kwargs) You also don't need the first setting of modified_date_time, since the second will happen whether or not self.id is set. Further, the code would be simpler to understand and maintain if, instead of touching them here, you used the auto_now=True option on the modified_date_time field of the model and the auto_now_add=True option on the created_date_time field of the model. (I don't remember whether, in your original post, you had some reason to, for example, store these times in a different timezone than Django's and the database's configurations.) Bill On Fri, Feb 8, 2013 at 11:20 AM, laxmikant ratnaparkhi wrote: > I have not trimmed traceback. This is ouput came on python manage.py shell. > > And one more thing I modified save method This looks like this: > >def save(self): > if not self.id: > self.created_date_time = datetimeToUTC() > self.modified_date_time = datetimeToUTC() > self.modified_date_time = datetimeToUTC() > super(ModelName, self).save() > if not self.uid: > self.uid = idmaptoalpha.getUID(self.id) > super(ModelName, self).save() > > Can you plz tell me if anything is wrong in it. > > Thanks again. > > *N.B.:*But I have not modified method for Django's Group Table. This is > only for the new Classed I created. > > Regards, > Laxmikant > > > On Thu, Feb 7, 2013 at 11:49 PM, Tom Evans wrote: > >> On Thu, Feb 7, 2013 at 12:16 PM, laxglx wrote: >> > >> > Hello Everybody, >> > >> > I'm going to create a Group using Django Group. >> > >> > I have two databases one is "master" and another is "slave" >> > In master I created a user and group as usual. >> > >> > And in slave database I tried like this: >> > >> > >> Group.objects.db_manager('slave').create(name="grp1") >> > >> > This returned an error : >> > >> > Traceback (most recent call last): >> > File "", line 1, in >> > File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", >> line >> > 138, in create >> > return self.get_query_set().create(**kwargs) >> > File "/usr/lib/python2.6/site-packages/django/db/models/query.py", >> line >> > 358, in create >> > obj.save(force_insert=True, using=self.db) >> > TypeError: save() got an unexpected keyword argument 'force_insert' >> >> Have you trimmed this traceback? >> >> > >> > I also tried as follows, but got error : >> > >> g = Group() >> g.name = "grp1" >> g.save(using='slave') >> > Traceback (most recent call last): >> > File "", line 1, in >> > TypeError: save() got an unexpected keyword argument 'using' >> > >> >> It looks like you have overwritten the save() method on the model you >> are trying to save, and have not given it a method signature capable >> of accepting the necessary arguments that save() is expected to >> handle. >> >> I say 'looks like', since I think you have obliterated the parts of >> the traceback that would tell me… >> >> save() takes many arguments. If you are not specifying any additional >> arguments for your save() method, then it should look like so: >> >> def save(self, *args, **kwargs): >> >> This protects you from having to change the method if more arguments >> are added in later versions of django, eg when the 'using' argument >> was added in 1.2. >> >> As usual, the docs have canonical instructions on how to override >> model methods like save(): >> >> >> https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-model-methods >> >> Cheers >> >> Tom >> >> -- >> 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
Re: IntegrityError when creating a brand new model instance
On 08/02/13 14:08, Andre Terra wrote: Please post traceback, settings.py, etc. On Fri, Feb 8, 2013 at 5:18 AM, Some Developer mailto:someukdevelo...@gmail.com>> wrote: I have a model for a Tag object with simply has two fields. A title (which has the unique constraint) and a description. I also have a FormView based view class which handles the creation of Tag objects. When I try and save the object in the form_valid() method I always get an IntegrityError stating that the title column is not unique. This is somewhat puzzling as I have deleted the SQLite database file and recreated it using syncdb / migrate so it is completely empty. I'm completely baffled by this error. Opps. I forgot to post the code. class TagCreate(FormView): template_name = 'blog/tag_create.html' success_url = reverse_lazy('blog_tag_create_confirmed') model = BlogTag form_class = CreateTagForm def form_valid(self, form): tag = BlogTag( title=form.cleaned_data['title'], description=form.cleaned_data['description'], num_articles=0) tag.save() return super(TagCreate, self).form_valid(form) -- 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.