I just tried GEdit and failed
I just tried GEdit on the basis of this thread to replace a very good but slow Komodo. GEdit is not good, or should I say, the plugins that let it be a python dev environment are not good. Perhaps I've selected and incompatible set of plugins, because they started off working somewhat decently, then syntax coloring was wrong for some files as though it was detecting the wrong language and the class browser turned blank, A lot of the plugins don't look like they've been touched in a few years so maybe they're unmaintained. Could someone post a list of of GEdit plugins that create a good django environment? Komodo Edit is very good except it's too slow. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to group by two fields simultaneously.
I have the following: Model Person Model Stat Model Stat Value Model Team A Team has a set of Stats relevant to it. A person is on multiple teams, and has stats for his/her performance on that team which are stored as Stat Values. Stat values are unique by Person, Stats, and Team. I want to build a view that will show team overviews from the point if view of a single specific person. All his/teams, and the associated stats. So my view throws out a list of teams, filtered to the person and my template looks like this: {% for t in teams %} {% for s in t.getStats %} ** I WANT TO NOW DO SOMETHING LIKE: ** {% for v in s.getStatValues(Person,s) %) ** EXCEPT THAT I CAN'T PASS ARGS IN A TEMPLATE. ** But if I don't pass in those arguments I'll get all the statValues for everyone on the team, not just the person I'm looking at. I wouldn't retrieve it all and then put an {% if v.person=p %} or similar in the template would I? This must be something fairly common. What am I doing wrong? It's an easy SQL statement to write, but how to do it Django style? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Database schema migration - any tools available?
Hi all, I have a migrations tool made by me for an internal project. I couldn't find anything at the time and I made my own. It uses the Command pattern (took the idea from the Rails migrations) and plain MySql queries with a parser made with Antlr ... I know it is not portable but this may be changed. MySql is used because that's all I use and because I was thinking of cool features like parsing the queries and creating visual diffs between two migrations ... that's for when I'll have enough time. Is there such a tool for Django? If there aren't any maybe I could package it and release it as open source ... otherwise it would be nice to work with a polished project (mine is just a quick hack with some potential). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cannot get user profile working.
I have a user profile defined in web.core.models.py and I cannot get this to work at all. I am constantly getting the following: >>> User.objects.get(username="Alex") >>> User.objects.get(username="Alex").get_profile() Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python25\lib\site-packages\django\contrib\auth \models.py", line 294, in get_profile self._profile_cache = model._default_manager.get(user__id__exact=self.id) AttributeError: 'NoneType' object has no attribute '_default_manager' I have set the following in settings.py (among a thousand other combinations). AUTH_PROFILE_MODULE = "web.webuserprofile" I have also tried: AUTH_PROFILE_MODULE = "web.core.webuserprofile" which gives me Too Many Values to Unpack. I have also tried to create a simple models.py that import core.webuserprofile.models.py but that didn't work either. Can someone please help me. This has cost me an unbelievable amount of time trying to get this going. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cannot get user profile working.
Thanks, worked perfectly. Not sure if it's just me and my lack of sleep or the docs aren't that clear on this item. I didn't see much regarding this on the Internet so there must not be scores of others making the same mistake. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANNOUNCE: Django 1.0 released
On Sep 4, 2:07 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > The Django team is pleased to announce the release of Django 1.0 this evening: > > Download:http://www.djangoproject.com/download/ > Release notes:http://docs.djangoproject.com/en/dev/releases/1.0/ > > Have fun with it, and we'll see you in a few days for DjangoCon. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." Thank you to all the Django developers and to all "perfectionists with deadlines" ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Working with inline formsets to created/edit an object
I am very interested in this as well. I had to abandon formsets because they were too difficult to get working for creating associated objects at the same time as the original object. I was sure this was a common issue but could find absolutely no information about how to do this reasonably cleanly, even reverse engineering the source. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb + AMD64
Try using Linux then. I just created an Ubuntu dev platform for Django on my AMD64 and everything worked very easily. You can even install Ubuntu from windows using Wubi -- practically a one-click install. Python, MySQL, and all the libs are all ready to go for AMD64, you just install using the package manager that comes with Ubuntu. Not sure what you use for an editor but most are available for Linux also. I found that MySQL for Windows was very tough to get working under Vista. Plus, if you are going to go live then chances are your hoster will be using unix-like software over Windows. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problem with the ImageField using ModelForm
Hi, i have a problem with the form.ImageField using ModelForm. I define a ImageField in my model and I configure all path in the settings file. I have no problem when i use the django admin interface : the images are uploaded correctly to the directory and correctly added in the DB. But when i use the form i make with ModelForm. Nothing append. I don't understand because i don't customise the form, i just exclude some fields. Is it possible there is a bug in ModelForm.ImageField ?? Thanks Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Json Serialization / Form Validation error
I ran into this same problem but the code snippets you guys gave weren't working. In case anyone is reading this in the future, here is what you want: dict([(k, [unicode(e) for e in v]) for k,v in errors.items()]) The above line will give a dictionary of field names mapping to lists of errors. HTH On Dec 17 2008, 1:42 am, Rodrigue wrote: > Hi Russell, > > I bumped into the same issue today and was glad I found this post. > However, I found that I had to use unicode() rather than str(), > which turns your example into: > > content = dict((key, [unicode(v) for v in values]) \ > for key, values in > form.errors.items()) > > With str() the proxy returns ' object at 0x83878ac>' (i.e. it only puts the name into quotes) > > On Oct 19, 6:14 am, "Russell Keith-Magee" > wrote: > > > On Sun, Oct 19, 2008 at 12:58 AM, justind wrote: > > > > Hello, > > > > No one has any ideas? > > > Settle down, Tiger. You asked this question on a Friday night. You may > > need to wait a little more than 18 hours if you want a response. > > We're all volunteers here, and many of us have professional and family > > obligations that take priority over answering questions on a mailing > > list. > > > To answer your question - although it may not be immediately obvious > > to you _why_ this is occurring, the error message you have received > > does tell you exactly _what_ is occurring. > > > Although form.errors appears to be a dictionary containing strings > > (i.e., a dictionay of lists of strings appear when you print > > form.errors), it's actually an ErrorDict that contains ValidationError > > objects. These, in turn, are manipulated in various ways to ensure > > correct unicode output - and one of those manipulations is the use of > > proxy objects (django.utils.functional.__proxy__). If you call str() > > on a proxy object, it will evaluate and return the underlying string, > > but the object itself isn't a string. > > > SimpleJSON (and the Django copy of the SimpleJSON library) only knows > > how to serialized basic Python types, so it complains when you give it > > a proxy object. This use of proxy objects in this way was something > > introduced by the introduction of full unicode support in Django. > > Jacob's slide predate the introduction of feature, which explains why > > the example he gave doesn't work out of the box with a more recent > > Django version. > > > However, If you force the rollout of the proxy objects before calling > > dumps(), SimpleJSON will correctly encode the form errors. Something > > like: > > > >>> simplejson.dumps(dict((key,str(v) for v in values) for key,values in > > >>> form.errors.items()) > > > should do the trick. > > > Yours, > > Russ Magee %-) > > > > The code I'm actually using in my view is almost identical to the > > > validage_contact view from > > >http://toys.jacobian.org/presentations/2007/oscon/tutorial/(single > > > slide:http://toys.jacobian.org/presentations/2007/oscon/tutorial/images/dja...) > > > and I'm using the JsonResponse function from those slides as well. > > > > Has something changed since these were published? Is this a bug? > > > > On Oct 17, 4:55 pm, "justin.don...@gmail.com" > > > wrote: > > >> Hello, > > > >> I'm having a hard time understanding why Django won't let me serialize > > >> a dictionary of form errors. Can anyone explain why Django throws an > > >> error if I try to serialize someform.errors, even if I copy it into a > > >> plain dictionary? > > > >> #!/usr/bin/env python > > >> from django.utils import simplejson > > >> from project.main.models import SampleForm > > > >> test = {} > > >> simplejson.dumps(test) # works > > > >> test = {'key': [u"value"]} > > >> simplejson.dumps(test) # works > > > >> # suppose SampleForms wants a text and url field > > >> # I just give it a text field to test > > >> form = SampleForm({"text": "sample text"}) > > >> d = {} # make a new dictionary > > >> # update d so we're working with a plain dictionary > > >> d.update(f.errors) > > >> type(d) # returns dict > > > >> # fails: > > >> # isnotJSONserializable > > >> simplejson.dumps(d) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-registration and django-profiles: common form
hello! I'm trying to make registration based on django-registration and django-profiles. What I want is to have initial form for not only with just login- password-email fields but also to add some custom fields from userProfile model. Can anybody help? How can I add additional fields? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there an example of html template usage?
http://www.satchmoproject.com/ good luck On Sep 10, 9:07 pm, aftalavera wrote: > Hi there, > > Where can I found sample about real apps usgin html templates with > Django templates? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
About forms.ChoiceField()
Hello all! First of all sorry for my english. I have made a small form, just 10 fields. now I see that page loads much slower then without this form... I found problem in this part of form: age = forms.ChoiceField(required=True, choices=AGE_CHOICES, initial='18') without this field page loads much faster! AGE_CHOICES = zip(range(18,100), range(18,100)) is it so big list of tuples for this function? can't believe it... any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
About forms.ChoiceField()
Hello all! First of all sorry for my bad english:) I have made a small form, only 10 fields. But now I see that page loads more than two times slower! I found problem in this field: age = forms.ChoiceField(required=True, choices=AGE_CHOICES, initial='18') without this field page loads much faster. So my question is... AGE_CHOICES = zip(range(18,100), range(18,100)) is this list of tuples so big for this functions? just can't believe it. any ideas? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: About forms.ChoiceField()
Thanks for reply, Jim. Hmm, just saved full page to disk. Almost the same time... now i think it's just cost of transferring of big select box. I'll make it a bit smaller. Gzip will help me I think) Thanks again. On May 16, 4:44 pm, Jim wrote: > > I have made a small form, only 10 fields. But now I see that page > > loads more than two times slower! > > Is the page twice as long with string that makes up the 88-choice > field? > > There is of course a cost to what you put on a page. Is the speed of > loading changed when you save the page to your filesystem and load it > as a static page? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: My Django powered website for web based learning
Good job! Didn't have much time to check the content but the first 4 or 5 videos seemed very interesting. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
convert NodeList back to string
Hi, What would be the best way to convert NodeList created from template back to a string? I'm trying to implement a two-pass rendering. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Apache 2.2.1 + Python 2.6.1 + mod_swgi on Windows - Internal Server Error 500
I just had to troubleshoot an installation of Django, trying to get it to run under mod_swgi with the specs mentioned above. I kept getting Internal Server Error 500, and checking the Apache logs found this: [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] mod_wsgi (pid=3460): Target WSGI script 'C:/xampp/django/testapp/_apache/ django.wsgi' cannot be loaded as Python module. [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] mod_wsgi (pid=3460): Exception occurred processing WSGI script 'C:/xampp/django/ testapp/_apache/django.wsgi'. [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] Traceback (most recent call last): [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] File "C:/ xampp/django/testapp/_apache/django.wsgi", line 6, in [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] import django.core.handlers.wsgi [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] File "C:\ \Python26\\Lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 8, in [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] from django import http [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] File "C:\ \Python26\\lib\\site-packages\\django\\http\\__init__.py", line 5, in [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] from urllib import urlencode [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] File "C:\ \Python26\\lib\\urllib.py", line 26, in [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] import socket [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] File "C:\ \Python26\\lib\\socket.py", line 46, in [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] import _socket [Fri Apr 30 10:03:49 2010] [error] [client 192.168.x.xxx] ImportError: DLL load failed: The specified module could not be found. After some Googling, it turns out the problem was with Python 2.6.1 under Windows. Installing the latest version, 2.6.5, solved this problem immediately for me. Hopefully this will be helpful to someone else! -Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to use render_to_response, ajax and javascript variables
Hi, Please can anyone help with an app architecture problem I am having? (I am quite new to Django) I have an app which which serves up XHR requests (via YUI3 io uitility) to urlpatterns. The views make HttpResponses using render_to_response like so: return render_to_response("registration/register.html", { 'form': form, }, context_instance=RequestContext(request)) That is all fine: The html content is rendered in the relevant div (using a YUI3 io's success callback) . But the problem I have - and I may be thinking about this in the wrong way - is that I also want to pick out some variables from the response to use in my js success callback. If I wasn't using django templating this could be straightforwardly achieved with a JSON response parsed client side. So my difficulty is that I want both a rendered template response and some JSON response in the same callback... I have thought about 'enriching' the render_to_response context with these additional variables, inserting them in hidden html fields and then querying the dom for their values - but that feels awkward and also means the response has to be added to the dom before the js can act on their values. This seems like a familiar nut that must be well documented somewhere... :) any help, pointers very appreciated. Thanks Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to use render_to_response, ajax and javascript variables
Thanks all. I may go with Matt's idea of serialising html + other data to json and decoding client side. I'm not totally keen though because this abandons a very nice rollup of functionality in django's render_to_response (I am not familiar with how to write the template as JSON and rendering to that. Keeping the template as html seems like the right thing to do). I was hoping you'd scream 'don't be daft - everyone does this...' :) Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to use render_to_response, ajax and javascript variables
Thanks all! I will try a combination of these pointers. server/client communication patterns seems to be a recurring theme (or nightmare!) of mine. This conversation has been very helpful and reassuring - I can see that the hard and fast rule is 'when in doubt, json it' Alex and thanks Matt for that json version info which was confusing me -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
reverse relationships and their creation
Hi, I am getting a 'QuerySet' object has no attribute 'reel_set' on a reverse relationship query. I am pretty sure the models are correct which has made me look at what else might be the problem. So far I have thought of: - no relationships instances have been created between the two models so effectively the set is empty which is a problem - is it? (this seems like an unlikely cause) - the 'Reel' model was created *after* instances of its foreign key had been created - so I am wondering if syncdb doesn't create the _set field - this also seems an unlikely cause of the problem as adding foreign keys to models with existing instances is likely to happen a lot during development - something to do with INSTALLED_APPS ? I have changed the order to ensure that the foreign key model (Reel) appears before the model it has a foreign key to. - other ideas? Thanks for any thoughts, Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: reverse relationships and their creation
Hi Daniel, Models - class Reel(models.Model): st = models.DateTimeField(auto_now_add=True) et = models.DateTimeField(auto_now=True) othermodel= models.ForeignKey(Othermodel) class Othermodel(models.Model): name = models.CharField(max_length=100, blank=False) Code - om = Othermodel(name="Test") om.save() count = om.reel_set.count() #this causes the error Thanks, Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
model instances, schema and template variables
Hi, Just want to know if this is the correct understanding of how model instances are passed to templates. If I load a model instance object into a template - is it the case that I also implicitly load in any instance objects it is related through foreign key fields? It seems that these, and in turn, any foreign keys those objects have, are also loaded. eg return render_to_response("startpage.html", { 'A': instance1, }, context_instance=RequestContext(request)) so in the template I can do things like: {{ A.fk_field.name }} {{ A.fk_field.another_fk_field.name}} Is this correct - and how should it be controlled - supposing I really do only want 'instance1' without FK following. Is it also the case if I want access to an instance's reverse relationship objects I have to explicitly load those into the template seperately? eg return render_to_response("startpage.html", { 'A': instance1, 'BList': instance1.other_set.all(), }, context_instance=RequestContext(request)) so in the template I can do {% for B in BList %} do something with B {% endfor %} Sorry if this is answered elsewhere but just couldn't find it! Thanks Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django has incorrect time
I'm having some strange behavior when using Django and Postgres. My system time zone is EDT and when running datetime.now( ) from a *Python* shell I get the correct time. If I run a Django shell through manage.py it is an hour behind. I similarly have set up a view on a web page to display the time and it is also an hour behind. Now this is where things get tricky. I have some database fields that default to datetime.now( ) and get updated to the same when changes occur to the objects the fields are contained in. The database gets the correct local time (say 10:30) but when these values are displayed by Django on a page they are again an hour behind. So, Django cannot present the correct value (one hour behind) to me, but somehow the correct time gets inserted in the database, and when directly displaying this value from the database in Django it is again one hour behind. It sounds like a time zone thing but I've tried setting Django to an eastern zone and also None (to use the system TZ) but neither seemed to make a difference. Any help here? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django has incorrect time
> Works fine here with Django 1.0.2-1+lenny1; which version do you have? Django 1.2.1 (installed manually, not through apt) on Kubuntu 10.04, Python 2.6.5, Postgres 8.4.4. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django has incorrect time
> TIME_ZONE = 'America/Los_Angeles' This actually led to the solution, which was a stupid error on my part. Somehow TIME_ZONE got into my settings.py file twice and I was changing the first instance, which was getting overwritten with the second instance (default Chicago TZ) later. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Best OS - VPS environment
FreeBSD On Mon, Aug 16, 2010 at 12:39 PM, Kenneth Gonsalves wrote: > On Mon, 2010-08-16 at 01:54 -0700, Dan wrote: > > What do people recommend? > > debian lenny > -- > regards > Kenneth Gonsalves > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-registration0.8 args on /activation/complete/
Hi, Thanks for great package - just stuck now on how to update app specific user profile on /activate/complete/ Although I have seen the code (re ln 80 in django-registration/ registration/views.py) I don't understand how to write the correct url pattern and view params to pick up the activated user in my view so as I can add some app specific data for each user. In the url pattern I have: url(r'^accounts/activate/complete/$' ,'myapp.views.profile', name='registration_activation_complete'), and in the view I want this sort of thing so as I can complete the UserProfile(this fails because the request.user is empty): def profile(request): new_user = request.user profile = UserProfile(user= new_user) and in the model: class UserProfile(models.Model): user = models.OneToOneField(User) st = models.DateTimeField(auto_now_add=True) ... I think the problem is not understanding what my view receives from the 'activate' redirect: if success_url is None: to, args, kwargs = backend.post_activation_redirect(request, account) return redirect(to, *args, **kwargs) I have tried setting a username parameter in the url pattern and view with no success. How should this be done? I need a - oh that's how it works - moment. Any help very appreciated. Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Connecting a django-registration signal to a function
Hi Kai, I have done this very similarly(after a lot of wrong ideas). I now have it working using 'connect' instead of 'send' def user_profile(sender, user, request, **kwargs): profile = UserProfile(user= user) profile.save() from registration.signals import user_activated user_activated.connect(user_profile) I picked this up from this thread : http://stackoverflow.com/questions/3114976/extending-django-registration-using-signals/3124006#3124006 Hope this helps. Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Multiple authentication sources to one database
I am trying to write an application that allows two different kinds of authentication: Users in the wild can register and use the site with a new username, password and email and authenticate as usual, and others can use a single-sign-on solution provided by my university. django- cas (http://code.google.com/p/django-cas/) and django-cas-provider (http://nitron.org/projects/django-cas-provider/) both handle the single-sign-on solution, but they overload the username field to correspond to the username provided by CAS. This means that if someone registers as "johndoe" then someone who authenticates as "johndoe" with CAS will suddenly have access to the internals of the other account. Is there a way to separate out these authentication methods so that both can be used on the same django installation? (They both need access to the same database of information.) If this isn't possible, I may try to create a whole second instance of django running on the same database (but then they both will want to use the "auth_users" table anyways). -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
terms of service (tos field) validation and error reporting from django registration package
Hi, Does anyone know how to get the error message in the form template when the user fails of check the terms of service form field when using RegistrationFormTermsOfService ? The form returns due to validation but I don't get the error message in {{ form.tos.errors }} . Any ideas? Is it anything to do with the tos field being a checkbox? Thanks Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Slug auto-complete after save
Hi all, Slug autocomplete feature is really cool with: prepopulated_fields = {'slug':('title',)} Is it possible to prepopulating slug field even after save - when I want to change title for example? Actually I use django-multilingual and prepopulating of slug works only for the first language (en for example), when I switch to another language tab (es for example) - the entity is already saved and I have now prepopulating for Spanish language. Is it possible to solve this issue somehow? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slug auto-complete after save
File "admin_modify.py" method "def prepopulated_fields_js(context)" Line 11: if context['add'] and 'adminform' in context: should be changed to if 'adminform' in context: to allow slug be auto updated every time and not only on the entity creation in admin. Is there any setting to do it without changing Django internal source code? On 24 Жов, 18:29, Alex wrote: > Hi all, > > Slug autocomplete feature is really cool with: > > prepopulated_fields = {'slug':('title',)} > > Is it possible to prepopulating slug field even after save - when I > want to change title for example? > > Actually I use django-multilingual and prepopulating of slug works > only for the first language (en for example), when I switch to another > language tab (es for example) - the entity is already saved and I have > now prepopulating for Spanish language. > > Is it possible to solve this issue somehow? > > Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
table namespace hygiene: should I try to rename auth_* tables, or should I use a separate database?
django 1.2, python 2.6, mysql 5.1, etc. I am sharing a database with others on my project, and I would like to keep the table namespace neat and tidy. After poking around the archives for a while, I can't see any good way to specify names other than the default auth_group, auth_group_permissions, etc. for the auth module. I don't want my tables to get confused with someone else's. "auth" is unfortunately a very generic prefix. One can imagine lots of people making tables named auth_something. Is this renaming something that can be done in a reasonable way? If not, I could create a new database, and devote it to the django stuff. Is that a good solution? Are there significant disadvantages to using a separate mysql database just for the django stuff? Is there maintenance overhead for the dba? (I don't know.) Are there any disadvantages, say, to doing trans-database joins, or having trans- database key constraints, vs. within a single database? Does anyone see any other optimal ways to keep my table namespace clean? Thanks Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: can't open file 'django-admin.py': [Errno 2] No such file or directory'.
On Oct 30, 1:00 am, sami nathan wrote: > Whenever I try to execute a python script that is located in the > /usr/local/bin, python gives me the error 'python: can't open file > 'django-admin.py': [Errno 2] No such file or directory'. Please type the following commands (without the $ prompt) and post the results: $ type python $ type django-admin.py $ head -3 /usr/local/bin/whatever-script-you-want-to-run -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: table namespace hygiene: should I try to rename auth_* tables, or should I use a separate database?
I poked around a little, and it looks like MySQL actually does support foreign keys across databases. I guess my questions are: As long as the separate databases are not explicitly distributed eg. to different machines or different CPUs, is there any disadvantage to joining or constraining across database boundaries? And/or is there a good way for me to customize the names of the tables created by eg., auth, to dampen my urge to use a different database just for the sake of namespace hygiene? (I'm thinking that the answer to this is "no".) Thanks Alex On Nov 1, 7:58 am, Scott Gould wrote: > > If not, I could create a new database, and devote it to the django > > stuff. Is that a good solution? Are there significant disadvantages to > > using a separate mysql database just for the django stuff? Is there > > maintenance overhead for the dba? (I don't know.) Are there any > > disadvantages, say, to doing trans-database joins, or having trans- > > database key constraints, vs. within a single database? > > I am not a database expert -- only know enough to get by -- but as far > as I am aware MySQL does not support foreign keys across databases. > That is, you can put the auth system anywhere you like, but anything > that references the auth models will need to be in the same database, > directly or indirectly. Very likely a road you don't want to walk down. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Internationalization problems in Django 1.2 (beta 1 SVN-12678)
I've got some very simply templates in which marking strings as translatable is not working. For example: --- snip {% extends "base.html" %} {% load i18n %} {% block content %} {% trans "Password reset successful" %} {% trans "You successfully resetted your password. A confirmation mail has been sent. Check your inbox for further instructions." %} {% endblock %} --- snip For example for this template, the first text is being translated. The second one is just printed like {% trans "The text..." %}. I'm using the trans-tag in a very simple way and exactly how I used it numerous times without running into problems. Do you have an idea on this? I tried everything that came to my mind - the problem persists. Could it be a problem of the development version? I didn't find anything on the tickets and bug reports... Hoping that I did not miss something very obvious :-) Thanks in advance Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Internationalization problems in Django 1.2 (beta 1 SVN-12678)
Posting this question made me rethink the problem... And it was a very small mistake: {% trans "..." %} is not able to mark multilined... Just use one line and everything will work. Hope this helps someone :-) Alex On 5 Mrz., 04:19, Alex wrote: > I've got some very simply templates in which marking strings as > translatable is not working. For example: > > --- snip > > {% extends "base.html" %} > {% load i18n %} > > {% block content %} > > {% trans "Password reset successful" %} > > {% trans "You successfully resetted your password. A confirmation mail > has been sent. Check your inbox for further instructions." %} > > {% endblock %} > > --- snip > > For example for this template, the first text is being translated. The > second one is just printed like {% trans "The text..." %}. > > I'm using the trans-tag in a very simple way and exactly how I used it > numerous times without running into problems. Do you have an idea on > this? I tried everything that came to my mind - the problem persists. > Could it be a problem of the development version? I didn't find > anything on the tickets and bug reports... > > Hoping that I did not miss something very obvious :-) > > Thanks in advance > > Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django SMTP and SPA
Hi. Can anybody suggest an idea how to deal with SMTP server with Secure Password Authentication in Django? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django SMTP and SPA
No. I've just googled a bit for SPA, SPA+python. But I did not find anything helpfull. On 13 апр, 18:44, Massimiliano della Rovere wrote: > i think the python modules > - smtplib > - email > will help. Have you already tried these ones? > > On Tue, Apr 13, 2010 at 14:58, Alex wrote: > > Hi. > > Can anybody suggest an idea how to deal with SMTP server with Secure > > Password Authentication in Django? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
IntegrityError: datatype mismatch
Hello all, I am having an issue with django models and the auto-generated admin page: I apologize if this has already been answered somewhere. /reg/models.py: ''' from django.db import models class Space(models.Model): name = models.CharField(max_length=100, )#unique=True) def __unicode__(self): return self.name class Admin: pass class Workshop(models.Model): name = models.CharField(max_length=100, )#unique=True) def __unicode__(self): return self.name class Admin: pass class Event(models.Model): space = models.ForeignKey(Space, edit_inline=models.TABULAR) workshop = models.ForeignKey(Workshop, edit_inline=models.STACKED) start = models.DateTimeField(core=True) end = models.DateTimeField() class Admin: pass ''' http://example.com/admin/reg/workshop/add/ works properly: I can add workshops with their associated events. However, when I attempt to add an event to a workshop that already exists, for example at http://example.com/admin/reg/workshop/1/, by selecting a space and filling in both the start and end date/time forms: "IntegrityError at /admin/reg/workshop/1/ datatype mismatch" I can provide the entire error message if so desired. thanks -Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User form input as variable for form action?
Hi there, Does anyone know if it's possible to take data input into a form by a user and use this data as a variable within the same form to populate a form action? My form is as follows: Date: {{ form.date }} {% if form.date.errors %}*** {{ form.name.errors|join:", " }}{% endif %} The date of the batch to save article profile to (-MM-DD) DOI: 10.1038/ {{ form.doi }} {% if form.doi.errors %}*** {{ form.name.errors|join:", " }}{% endif %} Perhaps this is not the right way to go about this though? If anyone has a solution it would be much appreciated. Thanks Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Printing out HTML that doesn't get converted to
I'm working on my first Django project and I can't seem to get information printed out as I would like it. I'm trying to print out quotes to a page with the newlines turned into HTML tags (similar to PHP's nl2br function). So far I've been able to do this using the __str__ function for the Quote model, but it escapes the tags into html entities that I see the tags in my browser instead of the line breaks. I'm using the development version of Django. Here's what my __str__ function looks like: return self.quote.replace('\n', '') And I'm just printing them out with a generic view that looks like this: {% for quote in object_list %} {{ quote }} {% for a in quote.authors.all %} —{{ a }} {% endfor %} {% endfor %} I'd appreciate any suggestions. I'm rather new to Python, so I appreciate all the help I can get :) --Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Printing out HTML that doesn't get converted to
Wow, that was incredibly simple. Thanks for the help! I have a strong feeling I'm not going back to PHP... --Alex On May 15, 4:47 pm, jonknee <[EMAIL PROTECTED]> wrote: > On May 15, 6:17 pm, Alex <[EMAIL PROTECTED]> wrote: > > > I'm working on my first Django project and I can't seem to get > > information printed out as I would like it. I'm trying to print out > > quotes to a page with the newlines turned into HTML tags (similar > > to PHP's nl2br function). > > You're looking for linebreaks, a filter in Django templates: > > http://www.djangoproject.com/documentation/templates/#linebreaks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Filtering by group
I'm playing around with a TV quotes database and I'm trying to get all quotes from one TV series. My problem is that the quotes are directly tied to an episode of a TV series, not the series itself. How can I easily get a queryset that represents all quotes from that series? Here's a snippet from my models.py (removing irrelevant info): class Source(models.Model): name = models.CharField(max_length=50) slug = models.SlugField(max_length=20) class Quote(models.Model): quote = models.TextField(max_length=500) authors = models.ManyToManyField(Author) source = models.ForeignKey(Source) class TVSeries(models.Model): name = models.CharField(max_length=50) slug = models.SlugField(max_length=20, editable=False) class TVEpisode(Source): series = models.ForeignKey(TVSeries) episodenum = models.IntegerField() In my view, I'm thinking of something like the following, which obviously doesn't work: queryset = Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug))) Is there an easy way to filter by groups like this? Thanks, Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Filtering by group
I'm not sure if this is any closer, but maybe it is: queryset = Quote.objects.filter(source in series.tvepisode_set.select_related()), There's something wrong with the "source in" part, though... On May 16, 3:39 pm, Alex <[EMAIL PROTECTED]> wrote: > I'm playing around with a TV quotes database and I'm trying to get all > quotes from one TV series. My problem is that the quotes are directly > tied to an episode of a TV series, not the series itself. How can I > easily get a queryset that represents all quotes from that series? > > Here's a snippet from my models.py (removing irrelevant info): > > class Source(models.Model): > name = models.CharField(max_length=50) > slug = models.SlugField(max_length=20) > > class Quote(models.Model): > quote = models.TextField(max_length=500) > authors = models.ManyToManyField(Author) > source = models.ForeignKey(Source) > > class TVSeries(models.Model): > name = models.CharField(max_length=50) > slug = models.SlugField(max_length=20, editable=False) > > class TVEpisode(Source): > series = models.ForeignKey(TVSeries) > episodenum = models.IntegerField() > > In my view, I'm thinking of something like the following, which > obviously doesn't work: > > queryset = > Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug))) > > Is there an easy way to filter by groups like this? > > Thanks, > Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Filtering by group
Alright, I think it works now with this: queryset = Quote.objects.select_related(slug) Much simpler than what I was trying... On May 16, 3:55 pm, Alex <[EMAIL PROTECTED]> wrote: > I'm not sure if this is any closer, but maybe it is: > > queryset = Quote.objects.filter(source in > series.tvepisode_set.select_related()), > > There's something wrong with the "source in" part, though... > > On May 16, 3:39 pm, Alex <[EMAIL PROTECTED]> wrote: > > > I'm playing around with a TV quotes database and I'm trying to get all > > quotes from one TV series. My problem is that the quotes are directly > > tied to an episode of a TV series, not the series itself. How can I > > easily get a queryset that represents all quotes from that series? > > > Here's a snippet from my models.py (removing irrelevant info): > > > class Source(models.Model): > > name = models.CharField(max_length=50) > > slug = models.SlugField(max_length=20) > > > class Quote(models.Model): > > quote = models.TextField(max_length=500) > > authors = models.ManyToManyField(Author) > > source = models.ForeignKey(Source) > > > class TVSeries(models.Model): > > name = models.CharField(max_length=50) > > slug = models.SlugField(max_length=20, editable=False) > > > class TVEpisode(Source): > > series = models.ForeignKey(TVSeries) > > episodenum = models.IntegerField() > > > In my view, I'm thinking of something like the following, which > > obviously doesn't work: > > > queryset = > > Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug))) > > > Is there an easy way to filter by groups like this? > > > Thanks, > > Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Link to different URLs by Class
I'd like to make a link to an item based on which class it is in. I'm creating a quotes database that has quotes from movies, tv shows, etc. Movie, TVShow, etc. are all separate classes, and they have separate URLs for viewing them. I'm trying to create a link to the source based on which subclass the source is in. For example, the movie subclass should have a link like /movie/slug and tv show should have a link like /tv/show/episodeslug and so on. I can do this quite easily when I know which subclass something belongs to (and therefore which URL to load), but I'm not sure how to do it when the subclass varies. To link to all quotes by a single author (the person that said the quote), I use this code in my template: {{ a }} Is there similar code (like a series of if statements) that could help me determine the context of the quote? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Outside a web server, as a service
Thanks Karen! alex On Jun 2, 5:18 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Jun 2, 2008 at 3:33 AM, Alexandre Parenteau <[EMAIL PROTECTED]> > wrote: > > > > > > > > > Hi, > > > I'm a newbie with Django, and I'm having trouble accessing django > > database outside the web server. > > > I'm using mod_python+apache+MySQL without any problem. > > > However I need for my project to *also* access the database *outside* > > of mod_python. I wrote a script service.py which is supposed to access > > periodically the database, as a background service: > > > > python service.py --service > > > This service.py file looks like this (the code was borrowed from > > settings.py): > > > >>>>>>>>>>>>>>>>>>>>> CUT > > from django.core.management import setup_environ > > try: > > import settings # Assumed to be in the same directory. > > except ImportError: > > import sys > > sys.stderr.write("Error: Can't find the file [...]) > > sys.exit(1) > > > print setup_environ(settings) > > > from djangoserver.myserver.models import Job, Dummy, ... > > > # XXX: (Temporary) workaround for ticket #1796: force early loading of all > > # models from installed apps. > > from django.db.models.loading import get_models > > loaded_models = get_models() > > > [...] > > <<<<<<<<<<<<<<<<<<<<< CUT > > > The script service.py then looks for jobs to work on: > > > >>>>>>>>>>>>>>>>>>>>> CUT > > while 1: > > > hadJob = doOneRun() > > if not hadJob: > > time.sleep(0.100) > > > # WORK AROUND: just to defeat the sql cache > > d = Dummy(foo="1") > > d.save() > > d.delete() > > <<<<<<<<<<<<<<<<<<<<< CUT > > > As you might see, I run into the problem that the Job table was not > > getting re-fetched my MySQL. I found a work around by creating a Dummy > > model, and by forcing an update on the table (d.save()). > > > Could someone point me to a way to do a background job with Django? Is > > there a cache I need to flush in order for Django to re-query the > > database? > > I think you must be using InnoDB tables? If so you are not running into any > Django cache but rather MySQL/InnoDB's default transaction isolation level > of repeatable read. Your problem sounds identical to the one posted here: > > http://groups.google.com/group/django-users/browse_thread/thread/e25c... > > and I expect it has the same possible fixes. > > Karen- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
media server implementation - context processor, custom template tag, or custom filter
I already have {{ MEDIA_URL }} set in html, css, and js templates and that's working great. I would like to start setting far future caching headers on media files based on the git abbreviated commit hash for each file. i can think of three options for implementing this and would appreciate feedback, especially in regard to the processing or performance penalties any of these approaches may incur. i've implemented proof-of-concept versions of all of them in development and they at least accomplish what I want, though I haven't yet done any benchmarking. as part of the production deployment process, a script is run which essentially does the following: for every static media file, find the git abbreviated commit hash which looks like "857vb4". the results are written to disk as a python dictionary: STATIC_ASSETS = { "/media/image/button.png": "/857vb4", "/media/image/submit.png": "/219cb3", etc. } the dictionary has approx 100 entries and may grow to 200. all of the approaches below generate html like this: http://media.example.com/857vb4/media/image/button.png";> http://media.example.com/219cb3/media/image/submit.png";> but the actual paths on disk do not include version numbers. apache has a re-write rule which removes the revision information, so that clients can be told to cache the static files for a long time into the future because whenever the file changes, the revision number in the url will change. here are some ways i've come up with for adding the revision info to the static file urls. 1) simple string filter templates look like this: and the template filter is approx: @register.filter @stringfilter def get_file_version(value, arg): if arg in STATIC_ASSETS: value = STATIC_ASSETS[arg] + arg; else: value = arg; return value 2) simple custom template tag templates look like: template tag code: @register.simple_tag def get_file_version(arg): value = arg if arg in ASSET_LIST: value = ASSET_LIST[arg] + arg; return value The third option would be a custom context processor which adds template variables to each page that are tied to the filename. Are these approaches reasonable or do they incur too much processing for, say, a page that has 10 or 20 static files (images, js, css)? Is there a better way I'm overlooking? I'm trying to avoid approaches which rename files on disk or do find-and-replace operations on template files. Any feedback appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Formsets or Forms with Subforms
I have been trying to find a fairly generic way of creating forms that fill related models similar to the admin method of presenting the main form and then multiple forms for related objects that can be added in batches (ex, the tabular form). This is a common requirement but I haven't been able to find any documentation. The web has some references to something called FormSets, which I think might do it but I don't know how to use them or if they even exist anymore, or if they will exist in a future version, or what. I found a couple of tutorials on how to build those types of forms using views/templates, but they are custom each time and I find I have to do the same thing over and over. Can anyone lead me to some documentation about how to do this? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Bill Gates thinks Google should be worried!
Hello Friends, Please go through the text. Bill Gates thinks Google should be worried! --- You must have heard by now about Agloco and how many people think it is going to be bigger than Google... Now Bill Gates is on record saying they have a great business model and that Google should be worried. Google makes billions of $$$ and keeps it all for itself... Agloco one day is going to also make billions of $$$ except it will be completely shared out to its members! You make money with Agloco by using your computer as you would normally! Join AGLOCO - Own the Internet! www.agloco.com/r/BBBV2104 Lastly if you're not convinced please read this report then come back and click on the link : http://simmonsreport.spaces.live.com/ --- Passive Income Online - Get rich or lose nothing It's all over the blogosphere and Bill Gates has been quoted as saying he believes it "will be the next big thing to hit the internet", so what is Agloco and will they really pay you for surfing the net? I too was skeptical when I heard about it but after spending a few hours googling and reading about it, I have not only come round to the idea but am now thinking it could really work and could really make us (that's me and all of you who are reading this) some money. How much does it cost me? Nothing What do I have to do? First you need to sign up, for free, and then you will need to download the viewbar - the viewbar is not ready yet but is expected to be ready for download in about 2-4 weeks. The viewbar will simply sit at the bottom of your screen whilst you browse the web, post to your blog, read other blogs, answer your email, Join AGLOCO - Own the Internet! www.agloco.com/r/BBBV2104 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Bill Gates thinks Google should be worried!
Hello Friends, Please go through the text. Bill Gates thinks Google should be worried! --- You must have heard by now about Agloco and how many people think it is going to be bigger than Google... Now Bill Gates is on record saying they have a great business model and that Google should be worried. Google makes billions of $$$ and keeps it all for itself... Agloco one day is going to also make billions of $$$ except it will be completely shared out to its members! You make money with Agloco by using your computer as you would normally! Join AGLOCO - Own the Internet! www.agloco.com/r/BBBV2104 Lastly if you're not convinced please read this report then come back and click on the link : http://simmonsreport.spaces.live.com/ --- Passive Income Online - Get rich or lose nothing It's all over the blogosphere and Bill Gates has been quoted as saying he believes it "will be the next big thing to hit the internet", so what is Agloco and will they really pay you for surfing the net? I too was skeptical when I heard about it but after spending a few hours googling and reading about it, I have not only come round to the idea but am now thinking it could really work and could really make us (that's me and all of you who are reading this) some money. How much does it cost me? Nothing What do I have to do? First you need to sign up, for free, and then you will need to download the viewbar - the viewbar is not ready yet but is expected to be ready for download in about 2-4 weeks. The viewbar will simply sit at the bottom of your screen whilst you browse the web, post to your blog, read other blogs, answer your email, Join AGLOCO - Own the Internet! www.agloco.com/r/BBBV2104 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
All about AGLOCO
Hi Friends, This note is mainly to offer you a chance to help build AGLOCO - it is a Member-owned Internet community. Here is why I would like you to help. First - it is free. Second - it is quick and easy to join. Third - AGLOCO's purpose is to get its members their share of the money generated on the Internet (i.e. you make money). And lastly - if you help build the AGLOCO network you can make much more. Here is a link to sign up www.agloco.com/r/BBBV2104 AGLOCO works with a toolbar type software called a Viewbar. Privacy is very strict so no spyware, popups or spam. As to how much money you can make, there is a study which says the average user should get $5 to $15 a month. (But less at the beginning.) Click here to read the report. http://simmonsreport.spaces.live.com How much can you make helping to build the network? The Simmons Report predicts $30 per referral. I have 200, but a friend of mine RZ McCall has over 8,000. He has a great blog site http://mccallsnotes.spaces.live.com . AGLOCO is in their beta phase which is the best time to help them build out the network. So please join now and help build the network. Have questions? Their website has all the details so go there www.agloco.com/r/BBBV2104. www.agloco.com/r/BBBV2104 Alexander --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
python manage.py sql [myapp] doesn't generate all the needed code ?
Hello all, I'm new to Django. :) I'm following the online tutorial. I'm created a application called "browser" and I'm writing my models. And I'm running into a subclassing problem. Here is my code: from django.db import models class BasicContact: contact_name = models.CharField(maxlength=50) contact_email = models.EmailField() contact_phone = models.CharField(maxlength=30) contact_mobile = models.CharField(maxlength=30) contact_fax = models.CharField(maxlength=30) contact_address = models.TextField(maxlength=200) contact_city = models.CharField(maxlength=50) contact_zipcode = models.IntegerField(maxlength=5) contact_country = models.CharField(maxlength=2) class Client(models.Model, BasicContact): name = models.CharField(maxlength=50) tv_channel = models.CharField(maxlength=50) web_site = models.URLField() comments = models.TextField(maxlength=1024) And then I'm getting the following mysql output: $ python manage.py sql browser BEGIN; CREATE TABLE `browser_client` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL, `tv_channel` varchar(50) NOT NULL, `web_site` varchar(200) NOT NULL, `comments` longtext NOT NULL ); COMMIT; Shouldn't it generate the needed code from subclassing ? : `contact_name` varchar(50) NOT NULL, `contact_email` varchar(75) NOT NULL, `contact_phone` varchar(30) NOT NULL, `contact_mobile` varchar(30) NOT NULL, `contact_fax` varchar(30) NOT NULL, `contact_address` longtext NOT NULL, `contact_city` varchar(50) NOT NULL, `contact_zipcode` integer NOT NULL, `contact_country` varchar(2) NOT NULL Any idea ? Regards, AC. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Handling millions of rows + large bulk processing (now 700+ mil rows)
Hello! Will you make the video available after the webcast? Thanks. On Saturday, June 30, 2012 7:10:27 PM UTC+4, Cal Leeming [Simplicity Media Ltd] wrote: > > Hi all, > > As some of you know, I did a live webcast last year (July 2011) on our LLG > project, which explained how we overcome some of the problems associated > with large data processing. > > After reviewing the video, I found that the sound quality was very > poor, the slides weren't very well structured, and some of the information > is now out of date (at the time it was 40mil rows, now we're dealing with > 700+mil rows). > > Therefore, I'm considering doing another live webcast (except this time > it'll be recorded+posted the next day, the stream will be available in > 1080p, it'll be far better structured, and will only last 50 minutes). > > The topics I'd like to cover are: > > * Bulk data processing where bulk_insert() is still not viable (we went > from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still > using the ORM - no raw sql here!!) > * Applying faux child/parent relationship when standard ORM is too > expensive (allows for ORM approach without the cost) > * Applying faux ORM read-only structure to legacy applications (allows ORM > usage on schemas that weren't properly designed, and cannot be changed - > for example, vendor software with no source code). > * New Relic is beautiful, but expensive. Hear more about our plans to make > an open source version. > * Appropriate use cases for IAAS vs colo with SSDs. > * Percona is amazing, some of the tips/tricks we've learned over. > > If you'd like to see this happen, please leave a reply in the thread - if > enough people want this, then we'll do public vote for the scheduled date. > > Cheers > > Cal > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/x7P21YF3MM4J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python-requests seems to 404 with Django/Tasty-pie?
I just discovered that the requests library honors HTTP_PROXY, but does not honor NO_PROXY. Based on what you say below, I'm betting this is your problem, or at least a part of it. One solution is for you to explicitly unset HTTP_PROXY when you don't want it. Another is for you to specify a proxies dict for requests. Good luck! Best Alex On Tuesday, October 2, 2012 2:31:52 PM UTC-7, Victor Hooi wrote: > > heya, > > Thanks for the tips - you're probably right, I might need to whip out > wireshark or something and see what exactly is going on. > > However, one thing I did notice - I normally have the http_proxy > environment variable set, as we use a HTTP proxy at work. > > However, if I unset the http_proxy variable, Python requests suddenly > seems to start working again. > > I tried to set the no_proxy variable, and put in localhost and 127.0.0.1 > in there - however, Python requests doesn't seem to respect that? > > Cheers, > Victor > > On Tuesday, 2 October 2012 22:48:26 UTC+10, Cal Leeming [Simplicity Media > Ltd] wrote: >> >> Hi Victor, >> >> I've had my fair share of exposure with python requests - so thought I'd >> chime in. >> >> On first glance, this looks to be an issue with specifying the port >> number into python-requests, doing so seems to send the entire " >> http://localhost:8000/api/v1/host/?name__regex=&format=json"; as the >> request. However, further analysis shows that might not be the case. >> >> Looking at the python requests code; >> https://github.com/kennethreitz/requests/blob/develop/requests/models.py >> >> >>> urlparse.urlparse("http://localhost:8080/test/url?with=params";) >> ParseResult(scheme='http', netloc='localhost:8080', path='/test/url', >> params='', query='with=params', fragment='') >> >> It then sends this directly into urllib3 using connection_from_url(); >> https://github.com/shazow/urllib3/blob/master/urllib3/connectionpool.py >> >> This then calls the following; >> scheme, host, port = get_host(url) >> if scheme == 'https': >> return HTTPSConnectionPool(host, port=port, **kw) >> else: >> return HTTPConnectionPool(host, port=port, **kw) >> >> get_host -> parse_url() >> https://github.com/shazow/urllib3/blob/master/urllib3/util.py >> >> Tracing through urllib3 finally gets to parse_url(); >> >> >>> urllib3.util.parse_url("http://localhost:8080/test/url?with=params";) >> Url(scheme='http', auth=None, host='localhost', port=8080, >> path='/test/url', query='with=params', fragment=None) >> >> So, lets look at path_url() instead; >> https://github.com/kennethreitz/requests/blob/develop/requests/models.py >> >> >>> lol = requests.get(" >> http://localhost:8000/api/v1/host/?name__regex=&format=json";) >> >>> lol.request.path_url >> '/api/v1/host/?name__regex=&format=json' >> >> Performing a test connection shows; >> >> foxx@test01.internal [~] > nc -p8000 -l >> GET /api/v1/host/?name__regex=&format=json HTTP/1.1 >> Host: localhost:8000 >> Accept-Encoding: identity, deflate, compress, gzip >> Accept: */* >> User-Agent: python-requests/0.11.1 >> >> So, from what I can tell, python requests is functioning normally. >> >> Personally, I'd say get wireshark running, or use the nc trick shown >> above, perform 1 request using curl and 1 using python requests, then >> compare the request headers. >> >> Can't throw much more time at this, but hope the above helps >> >> Cal >> >> On Tue, Oct 2, 2012 at 8:54 AM, Victor Hooi wrote: >> >>> Hi, >>> >>> I have a Django app that's serving up a RESTful API using tasty-pie. >>> >>> I'm using Django's development runserver to test. >>> >>> When I access it via a browser it works fine, and using Curl also works >>> fine: >>> >>> curl >>> "http://localhost:8000/api/v1/host/?name__regex=&format=json<http://localhost:8000/api/v1/host/?name__regex=&format=json> >>>> " >>> >>> >>> On the console with runserver, I see: >>> >>> [02/Oct/2012 17:24:20] "GET /api/v1/host/?name__regex=&format=json >>>> HTTP/1.1" 200 2845 >>> >>> >>> However,
unique_together constraint on a ForeignKey field in MySQL
I asked this originally on StackOverflow, but I realized you guys might have more experience with these gnarly edge cases: http://stackoverflow.com/questions/7131639/how-can-i-have-a-unique-together-constraint-involving-a-foreignkey-field-in-mysql Thanks for your consideration, -- Alex Ogier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I can't span relationships in list_filter
Django 1.3 supposedly supports spanning model relationships in list_filter, but when I try to use this feature, the admin page redirects me to an unfiltered page. For example, I have an admin list page for a class that looks like: class PlayerAdmin(admin.ModelAdmin): model = Player list_filter = ('team__year',) When I go to the admin list page, I see the options to filter by year along the right hand side, and they are correctly populated with the distinct years I have in the database. But if I click on an option (which says it will go to /?team__year=2010 in the status bar) I get redirected to /?e=1. This clears any other filters I have set up as well. Does anyone know why this is happening? Do you need any more information to diagnose the problem? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model Inheritance and ModelForms
I've been scouring Google and the Django documentation and I can't figure out how to do this. I'm working on an inventory management system for my shop. My inventory models.py similar to the following: class ItemType( models.Model ): def __unicode__( self ): return "blah blah blah" itemType = models.CharField( max_length = 32 ) isBook = models.BooleanField() class InventoryItem( models.Model ): def __unicode__( self ): return "blah" itemType = models.ForeignKey( ItemType ) description = models.CharField( max_length = 256 ) class InventoryBook( InventoryItem ): def __unicode__( self ): return "blah blah" title = models.CharField( max_length = 64 ) In my web app, I create a ModelForm based on InventoryItem and present that to the user. Upon submission, the POST data is used to create an instance of InventoryItem. I then check to see if inventoryItem.itemType.isBook() is True - if True, I want to cast inventoryItem to an InventoryBook type so I can set the extra fields and call save() so that it creates records in both tables in the MySQL database. I started trying to add a method to InventoryItem that would return an InventoryBook instance after being given the title string, but that doesn't work because Python doesn't have prototyping/forward declarations. Am I approaching this completely wrong, or am I just overlooking something simple? Any advice or links to relevant documentation would be *much* appreciated. Thanks! -Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model Inheritance and ModelForms
Tom, Thanks for the quick reply! However, when I tried that I got an error saying that inventoryitem "is an invalid keyword argument for this function". I fixed this by manually specifying the OneToOneField relationship with the parent class as inventoryItem and setting parent_link=True. With that in place, I get errors about InventoryItem fields not being allowed to be null within InventoryBook. This doesn't make sense to me since InventoryBook should only have a link to the parent and its own local book-specific fields - not the fields previously declared in the parent InventoryItem. I have not declared any models to be abstract (and in fact have not declared Meta: at all). If I need to manually specify all of the InventoryItem fields again in the constructor of the InventoryBook, I can. But doing so seems to defeat the purpose of using inheritance to begin with. Is there something I'm still overlooking? Thanks again, -Alex On Oct 28, 5:53 am, Tom Evans wrote: > On Fri, Oct 28, 2011 at 7:50 AM, Alex wrote: > > I've been scouring Google and the Django documentation and I can't > > figure out how to do this. I'm working on an inventory management > > system for my shop. My inventory models.py similar to the following: > > > class ItemType( models.Model ): > > def __unicode__( self ): > > return "blah blah blah" > > > itemType = models.CharField( max_length = 32 ) > > isBook = models.BooleanField() > > > class InventoryItem( models.Model ): > > def __unicode__( self ): > > return "blah" > > > itemType = models.ForeignKey( ItemType ) > > description = models.CharField( max_length = 256 ) > > > class InventoryBook( InventoryItem ): > > def __unicode__( self ): > > return "blah blah" > > > title = models.CharField( max_length = 64 ) > > > In my web app, I create a ModelForm based on InventoryItem and present > > that to the user. Upon submission, the POST data is used to create an > > instance of InventoryItem. I then check to see if > > inventoryItem.itemType.isBook() is True - if True, I want to cast > > inventoryItem to an InventoryBook type so I can set the extra fields > > and call save() so that it creates records in both tables in the MySQL > > database. > > > I started trying to add a method to InventoryItem that would return an > > InventoryBook instance after being given the title string, but that > > doesn't work because Python doesn't have prototyping/forward > > declarations. > > > Am I approaching this completely wrong, or am I just overlooking > > something simple? Any advice or links to relevant documentation would > > be *much* appreciated. Thanks! > > > -Alex > > If you have an InventoryItem which should be an InventoryBook, you > need to create the InventoryBook, not cast to it. > > item = … > if item.itemType.isBook(): > book = InventoryBook.objects.create(inventoryitem=item, title=…) > > Inheritance like this in django isn't really like OOO inheritance, > InventoryBook just magically gains a OneToOneField back to > InventoryItem called inventoryitem. > > Cheers > > Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
prefetch_related - possible to avoid "IN" ?
Hi - I am using prefetch_related as an efficient way to populate a large list of objects whose attributes that are one-to_many relationship. We have cases where we return a list of around 10,000 objects. This produces an SQL query with an "IN" clause and a list 10,000 IDs. Is it possible to instruct pretch_related to not use the list of objects but to use the query that produced the list instead? Or to explicitly give pretech_related a query to use? If that is not possible is there another way to go about this? Thanks! --Alex -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Django mysql over ssl (2026, 'SSL connection error: Failed to set ciphers to use')
Hi, Summary: I'm getting this error "(2026, 'SSL connection error: Failed to set ciphers to use')", on the django error page and I don't know what i happening!!! I'm using apache / wsgi and my aplication it's on a virtualenv. The main problem is that I can't connect to a remote mysql over ssl. The first think checked was the ssl configuration... but it's all rigth becouse I can run all django commands, (runserver too) without any problem, and the aplications it's connecting to the remote database over ssl correctly. The next think checked was runserver response and the application doesn't raise any error... it works perfectly... With that two points i can see that the problem is in the wsgi, specifically with the libraries that load to run the application becouse it's the only think that I can see that is diferent from a runserver (executed inside the virtualenv) Anyone have had the same problem or can give me ant clue, I'm spending a lot of hours tryng to solve that. The next test will be change to nginx to see if the problem persist.. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1cc91575-3657-41f8-b68d-50bb5d4e4ef8%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
queryset._clone() in generic views
What is 'queryset = queryset._clone()' statement in django.views.generic.list_detail.object_list view used for? Has it something to do with prevention of usage of cached results, to allow QuerySet to reflect changes made to the database? Should I use _clone(), too, if I'm reimplementing this view in order to add some filtering? Or, maybe, I should use QuerySet.all() method instead (i.e., 'queryset = queryset.all())? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
fetching data from intermediate many-to-many table
Hello! Assume we have the following models: class Book(models.Model): title = models.CharField() sequences = models.ManyToManyField(Sequence, through='BookSequence') class Sequence(models.Model): name = models.CharField(unique=True) class BookSequence(models.Model): class Meta: unique_together = ('book', 'sequence') book = models.ForeignKey(Book) sequence = models.ForeignKey(Sequence, related_name='detail') number_in_sequence = models.IntegerField() ...and are trying to select the sequences a concrete book belongs to, along with the number of this book in the sequence: def print_book_sequences(): book = Book.objects.get(pk=1) for seq in book.sequences.select_related(): number_in_sequence = seq.detail.get(book=book, sequence=seq).seq_number print seq.name, number_in_sequence So, the question is: Is there any way in django to select sequence name and sequence number in one sql query? The code in print_book_sequences results in two sql queries per sequence, one selecting name and one number. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Personalise activation from email django registration 0.8
Hi, Thanks for the nice sugar of django registration. Has anyone figured out how to get the username of a new user account into the activation email? Personalising the experience is more likely to get activation clicked. Ideas? Thanks in advance, Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: MultiValueDictKeyError in Django admin edit inline generic model
I am having a similar problem that started when I upgraded from django 1.4.x to 1.6.5 My parent model has a custom pk and the model in my inline is using the default autogenerated id. Here is some snippets from my models and admin: (note I have edited down for simplicity and have not tested the code below) class Transaction(models.Model): form = models.ForeignKey(Form) code = models.CharField(max_length=4) class Form(models.Model): form_id = models.CharField(max_length=255, primary_key=True) form_type = models.CharField(max_length=5) notes = models.TextField(blank=True) # admin class TransactionInline(admin.TabularInline): model = Transaction fields = ('code', ) extra = 0 class FormAdmin(admin.ModelAdmin): list_display = ('form_type',) readonly_fields = ('form_type', 'form_id') fields = ('form_type', 'form_id', 'notes') inlines = [ TransactionInline, ] admin.site.register(Form, FormAdmin) On Wednesday, July 9, 2014 11:44:30 PM UTC-4, sacrac wrote: > > Hi, me again :) i forgot mention a use the latest release django 1.6.5 and > python 2.7.5 > > any help or tips? > > thank. > > > On Wed, Jul 9, 2014 at 9:38 PM, carlos > > wrote: > >> Hi, i have this error when i edit the data, is similar error the next >> link >> >> >> http://stackoverflow.com/questions/19741314/multivaluedictkeyerror-in-django-admin >> >> but the only different is i use generic relation, this is my models.py >> >> class Photos(models.Model): >> name = models.CharField(max_length=150) >> imagen = ImageField(upload_to='photos', blank=True, null=True) >> >> content_type = models.ForeignKey(ContentType) >> object_id = models.PositiveIntegerField() >> content_object = generic.GenericForeignKey('content_type', 'object_id') >> >> >> def __unicode__(self): >> return self.name >> class Meta: >> verbose_name_plural = "Photos" >> >> and here my other models.py use the model generic Photos >> >> class Portfolio(models.Model): >> service = models.CharField('Nombre del servicio', max_length=250) >> date = models.DateField() >> link = models.URLField(blank=True) >> >> photos = generic.GenericRelation(Photos) >> >> def __unicode__(self): >> return self.service >> >> and this my admin.py >> >> class PhotosAdminInline(generic.GenericTabularInline): >> model = Photos >> extra = 1 >> >> class PortfolioAdmin(admin.ModelAdmin): >> inlines = [PhotosAdminInline] >> >> . >> >> when i save the portfolio the fist time only 1 pic or 2 or 3 etc NOT have >> error >> but when i need edit and add new photo i have this error >> >> MultiValueDictKeyError at /admin/portfolio/portfolio/6/ >> >> "u'photos-photos-content_type-object_id-0-id'" >> >> >> maybe this is a bug in Django? >> >> >> Cheers >> >> > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8ee68417-8dbb-4168-a753-0074f78aff7b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Listening to a django channel from outside a consumer
Hi, The docs explain that it is possible to publish to the channel layer from outside of a consumer: https://channels.readthedocs.io/en/latest/topics/channel_layers.html#using-outside-of-consumers I need to do the opposite. I have a fairly complex python script that reads live data from pubnub, processes it, and pushes it to consumers via groups on the channel_layer. This works fine, but I need consumers to be able to announce their presence to this script so that it can push them data (it currently pushes to the channel layer only when it gets new data from pubnub, which could be every 24 hours). I've decided to solve this by having the consumers publish to a 'presence' channel on connect. I now need the pubnub source script to listen to this channel. I've tried adding the below to the script, and it no longer throws errors, but it doesn't actually respond to messages. It successfully joins the channel layer, but the message handler 'receive_json', never fires. This is the class, and then the initiation further down in the code: from channels.generic.websocket import JsonWebsocketConsumer class channelConsumer(JsonWebsocketConsumer): def __init__(self): self.channel_name = 'source' def join(self): async_to_sync(channel_layer.group_add)('presence', self.channel_name ) def receive_json(self, message): print("Presence Detected") # do some stuff global channel_layer channel_layer = get_channel_layer() global listener listener = channelConsumer() listener.join() -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08086bed-67a8-4fd6-8eec-0c417423ea8b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: why not django's default server?
On Sat, Oct 25, 2008 at 12:27 AM, gniquil <[EMAIL PROTECTED]> wrote: > The reason I don't want to use apache is primarily due to 1. restarts Why not use Apache with mod_wsgi? Then, you just touch a file to reload your new code. No restart needed. /alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Access the current instance from limit_choices_to?
Hi, is there currently a way to have something like: class Mother(models.Model): firstborn = models.ForeignKey('Child', limit_choices_to={'mother':lambda me: me}) class Child(models.Model): mother = models.ForeignKey('Mother', related_name='children') (taken from http://code.djangoproject.com/ticket/2445 ) Basically I'd like to have access to the current instance of the class, when working with limit_choices_to. Of course we can't use self (we're still defining the class). Thank you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Access the current instance from limit_choices_to?
Also discussed here: http://groups.google.com/group/django-users/browse_thread/thread/51228899c5a9a6c/d49271983401e29e "If my original post was not entirely clear, I'm interested in any method available to limit_choices_to that lets you dynamically create the list of available options as a function of the current model instance. " On Mon, Oct 27, 2008 at 1:16 PM, Alex Rades <[EMAIL PROTECTED]> wrote: > Hi, > is there currently a way to have something like: > > class Mother(models.Model): >firstborn = models.ForeignKey('Child', > limit_choices_to={'mother':lambda me: me}) > > class Child(models.Model): >mother = models.ForeignKey('Mother', related_name='children') > > (taken from http://code.djangoproject.com/ticket/2445 ) > > Basically I'd like to have access to the current instance of the > class, when working with limit_choices_to. Of course we can't use self > (we're still defining the class). > > Thank you! > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Adding properties to models at run-time.
Hi, I've been trying for some time to create a polymorphic link with a backwards-link from the associated model. The problem is the model is django.contrib.auth.models.User... Is there any way to add this functionality without changing the django core? Trying to call setattr(django.contrib.auth.models.User, 'target', generic.GenericRelation(MyUser) does not work. It instantiates an attribute named 'target', but it doesn't work in the manner intended... from django.contrib.auth.models import User as Account from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic class User(models.Model): account_polymorphic_link = models.ForeignKey(ContentType) account_id = models.PositiveIntegerField() account = generic.GenericForeignKey('account_polymorphic_link', 'account_id') setattr(Account, 'target', generic.GenericRelation(User)) #this doesn't seem to work My problem is that I'm using auth.User (Account in the above example) to store username/password and to leverage permissions and such, but I can't look someone up by username and get at the information in my derivative class... Does anyone have any ideas/suggestions? Thank you, Alex. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding properties to models at run-time.
Thanks for the reply, DR. How would I use the generic relationship without the backward link? I have the normal auth.user class, and I have the my.user class that extends it and has a polymorphic link pointing at auth.user. The problem occurs when I collect a login/password, because I can't lookup my.user without the backward link, that is I can't my.user.filter(account__username = x, account__password = y) because polymorphic links don't allow this. I also can't move in reverse, the auth.user.authenticate(username, password) function returns an auth.user, and I am unclear as to how I would get a my.user from this information without calling for my.user.objects.all() and comparing the link (which seems terribly, terribly inefficient...). Is there a way to start with the target (auth.user) and get to my.user backward via the contenttype? I know about AUTH_PROFILE_MODULE, but the problem is that the goal is to have multiple user classes. Ideally there would be a way to specify the user model as an attribute of the auth.user model (which would be the heretofore missing backward link), but barring that this isn't much use to me because the AUTH_PROFILE_MODULE would have multiple values. Any clues? Thanks, Alex. On Oct 30, 4:33 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Oct 30, 8:11 pm, Alex G <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I've been trying for some time to create a polymorphic link with a > > backwards-link from the associated model. The problem is the model is > > django.contrib.auth.models.User... Is there any way to add this > > functionality without changing the django core? Trying to call > > setattr(django.contrib.auth.models.User, 'target', > > generic.GenericRelation(MyUser) does not work. It instantiates an > > attribute named 'target', but it doesn't work in the manner > > intended... > > > from django.contrib.auth.models import User as Account > > from django.contrib.contenttypes.models import ContentType > > from django.contrib.contenttypes import generic > > class User(models.Model): > > account_polymorphic_link = models.ForeignKey(ContentType) > > account_id = models.PositiveIntegerField() > > account = generic.GenericForeignKey('account_polymorphic_link', > > 'account_id') > > > setattr(Account, 'target', generic.GenericRelation(User)) #this > > doesn't seem to work > > > My problem is that I'm using auth.User (Account in the above example) > > to store username/password and to leverage permissions and such, but I > > can't look someone up by username and get at the information in my > > derivative class... > > > Does anyone have any ideas/suggestions? > > > Thank you, > > > Alex. > > Well, you can use generic relations without the backwards link, by > simply looking up the content_type/object_id in the related class. > > But for your use case, a much better way is to use the built-in > AUTH_PROFILE_MODULE setting, which allows you to nominate a class > which extends User, and enables a user.get_profile() method. > Seehttp://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-... > > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Overriding update in models
Hi, Antonio. Try to replace `datetime.date.today()` with `datetime.datetime.now()` calls. On Tue, Nov 4, 2008 at 23:58, Antonio Volpon <[EMAIL PROTECTED]>wrote: > > Hello. > > I am very new to Django and I'm having some problems in overriding the > save method for a simple class. In particular, the following code > (models.py) used against a Mysql database doesn't change the value of > the two date fields when i save the page in admin, while it correctly > changes the value of description. I think I'm doing something > completely wrong, right? > > Thanks a lot, > Antonio > > import datetime > from django.db import models > > class Object(models.Model): >description = models.CharField(max_length=255) >insert_date = models.DateTimeField(editable=False) >update_date = models.DateTimeField(editable=False) > >def save(self): >if not self.id: >self.insert_date = datetime.date.today() >self.update_time = datetime.date.today() >super(Object, self).save() > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use post_save signal
Make `update_stock_status` a free function not `Sale` method. On Wed, Nov 5, 2008 at 12:43, Low Kian Seong <[EMAIL PROTECTED]> wrote: > > My code is here > > http://dpaste.com/88831/ > > It's not working I really don't know why the other part of the > post_save is not even being executed > > On Wed, Nov 5, 2008 at 4:04 PM, Antoni Aloy <[EMAIL PROTECTED]> wrote: > > > > 2008/11/5 Low Kian Seong <[EMAIL PROTECTED]>: > >> > >> Dear all, > >> > >> I am using django to write an a web based sales inventory system for > >> my client. To this end, I have created two objects in my models which > >> is : > >> > >> Sales and Stock. Everytime a sales is associated with a particular > >> stock is created, I want to update the Stock object's status field as > >> 'Sold'. Asking on the #django channel, they suggested I override the > >> save method for the model which lead me to finally try out the > >> post_save signal. > >> > >> I tried out most of the examples and tried to associate my method > >> which actually will try to get the particular stock object based on > >> the foreign key entry from Sales and update that object's 'status' > >> field. This however does not work. I tried to put the > >> signals.post_save.connect method in my __init__.py file and models.py > >> file but the code is not executed. Can someone please point me to a > >> project or url which has a more complete example for using the signals > >> and post_save? It seems like a very powerful component of the django > >> architecture. > >> > >> Thank you in advance. > > > > This is an example about how to register a delete signal to save the > > deleted user to a table called Eliminat, save should be nearly the > > same. > > > > You can put the in your models file, but be sure you have the > > application model in the settings.py file. > > > > {{{ > > def registra(sender, **kwargs): > ># get the instance > >instancia = kwargs['instance'] > ># Creates the object who's going to store the username > >usuari = Eliminat(user=instancia.username) > ># and the save it > >usuari.save() > > > > pre_delete.connect(registra, sender=User) > > > > }}} > > > > Hope it helps! > > > > Best regards, > > > > -- > > Antoni Aloy López > > Blog: http://trespams.com > > Site: http://apsl.net > > > > > > > > > > > -- > Low Kian Seong > blog: http://lowkster.blogspot.com > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: redirection 2 links back after signing up?
And how about to ignore `next` param in `create_account` view and explicitly redirect user to his restricted area? On Wed, Nov 5, 2008 at 17:12, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote: > > Hello, > > I have the following situation: > > 1) User goes to a restricted area and is offered a chance to login > (@login_required decorator used) > 2) User logs in, and then is automatically returned to this page via ? > next={{ request.path }} in the HTML template > > This works fine, after logging in the user is returned to the correct > page. > > The problem is, if the user doesn't already have an account, I get > into this situation: > > 1) User goes to a restricted area and is offered a chance to login > (@login_required decorator used) > 2) User doesn't have an account, so attempts to create one, and clicks > on the 'Create New Account link'. The problem is the link now looks > like: "/create_account/?next=/Sign_In/" > 3) After creating the account, the user is redirected to the sign in > page, but _not the page they visted 2 steps back_ > > Is there an ideal way to fix this? Basically, if you click on 'create > an account' from the sign_in page, there should be some way to return > to the page you were at before being directed to the sign in page. > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to output JSON like this?
With simplejson module (that is part of django distribution) you can covert to JSON any python objects. So create data structure you need and pass it to simplejson dump/dumps functions. On Thu, Nov 6, 2008 at 01:17, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hi, > > Ok I'm using the following code to turn my model into JSON: > > from django.core import serializers > json = serializers.serialize("json", Event.objects.all()[:5], > fields=('title','date','location')) > > Now, this returns JSON like this: > > [ >{ "pk": 1, "model": "events.event", "fields": { >"date": "2008-11-04 00:00:00", "location": 1, "title": > "Event 1"} >}, >{ "pk": 2, "model": "events.event", "fields": { >"date": "2008-11-04 00:00:00", "location": 1, "title": > "Event 2"} >}, >{ "pk": 3, "model": "events.event", "fields": { >"date": "2008-11-05 00:00:00", "location": 1, "title": > "Event 3"} >}, >{ "pk": 4, "model": "events.event", "fields": { >"date": "2008-11-05 00:00:00", "location": 1, "title": > "Event 4"} >}, > ] > > But I want it to output like this: > > [ >{ 'date' : '2008-11-04 00:00:00', 'dayEvents' : [ >{ 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, >{ 'title' : 'Event 2', 'location' : '1', 'id' : '2' } >]}, >{ 'date' : '2008-11-05 00:00:00', 'dayEvents' : [ >{ 'title' : 'Event 3', 'location' : '1', 'id' : '3' }, >{ 'title' : 'Event 4', 'location' : '1', 'id' : '4' } >]} > ] > > The main difference is that the events are grouped by date, which > makes it easier for me to loop through them the way I want to. > > Any ideas on how to achieve this, been looking in the documentation > but nothing in there from what I can see :( > > The event model looks like this: > > title= models.CharField(max_length=200) > date = models.DateTimeField() > location = models.IntegerField(choices=LOCATION_CHOICES, default=1) > > Cheers, > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Upload Progress Bar
And what error message do you receive? On Thu, Nov 6, 2008 at 09:46, Pawel Pilitowski <[EMAIL PROTECTED]>wrote: > > Hi all, > > I'm in the process of trying to write an Upload Progress Bar for my app. > > I'm using the latest trunk version of Django, mod_python 3.3.1, > Memcached, Apache 2.2.8 prefork, and YUI 2.6. > > I cannot seem to access the values stored in the cache during upload > (hoping to retrieve the 'uploaded' value for updating the progress > bar), however I can access them once the file has been successfully > uploaded. Are there issues with this setup that will not allow this, > or is it an issue with my logic? > > The code is largely inspired by the http://www.fairviewcomputing.com/ > blog/2008/10/21/ajax-upload-progress-bars-jquery-django-nginx/ example. > > I've tried to only show what's relevant, and some of the JS is just > there to test the concept. > > upload_progress view > http://dpaste.com/89036/ > > UploadHandler > http://dpaste.com/89037/ > > YUI JS save method > http://dpaste.com/89038/ > > I just want to be able to access the cache to return a JSON object > during upload. > Any help would be greatly appreciated. > > Cheers > > Pawel > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n strategy
The is an existing db internalization application - http://code.google.com/p/django-multilingual/. Try to look at it. On Thu, Nov 6, 2008 at 11:20, Brandon Taylor <[EMAIL PROTECTED]>wrote: > > Hi everyone, > > I'm tasked with translating a mostly database-driven site into > Spanish. I'm familiar with how to use Django's internationalization on > static strings in templates, but not with text coming from a database, > so I'm looking for some best practices advice... > > Should I: > > 1. Make a separate field for each translation and add a method in the > model to return the correct translation to use in templates? > > 2. Make a separate table for translations in general with a foreign > key to the original record and look up the translation that way? > > Advice appreciated! > Brandon > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practice
> Profile.objects.create(name=name, foo=foo) How do you get this `name` and `foo` variables in `save` method? On Thu, Nov 6, 2008 at 08:20, meppum <[EMAIL PROTECTED]> wrote: > > I've run into a funny case and I'm not sure how to best deal with it. > Basically, I have the following classes. > > class Profile(models.Model): >name = models.CharField() >foo = models.PositiveIntegerField(blank=True, default=0) > > class RegistrationForm(forms.Form): >name = forms.CharField() >foo = forms.IntegerField(min_value=0, max_value=55, > required=False) > > def save(self): > Profile.objects.create(name=name, foo=foo) > > If I pass in the following dictionary to RegistrationForm and save it > I get a constraint error that foo cannot be NULL. > > { >'name': 'test', > } > > I came up with two work arounds: Setting foo to 0 in the clean method > if it is None, or changing the save method in the RegistrationForm to: > > def save(self): > profile = Profile.objects.create(name=name) > if foo: > profile.foo = foo > profile.save() > > I was wondering if there is a way to handle this case without either > of these workarounds? It's a long shot, but I figured maybe there was > a more elegant way that I wasn't aware of. Thanks. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to output JSON like this?
It's strange. I've just try this example and it is good: In [1]: results = [] In [2]: results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' : ...: [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, { 'title' : ...: 'Event 2', 'location' : '1', 'id' : '2' } ] } ) In [3]: from django.utils.simplejson import dumps In [4]: dumps(results) Out[4]: '[{"date": "2008-11-04 00:00:00", "dayEvents": [{"id": "1", "location": "1", "title": "Event 1"}, {"id": "2", "location": "1", "title": "Event 2"}]}]' On Thu, Nov 6, 2008 at 12:13, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hey Alex, > > I tried this hard coded JSON the other day: > > results = [] > results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' : > [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, { 'title' : > 'Event 2', 'location' : '1', 'id' : '2' } ] } ) > > But I got an error when I did this (can't remember the error exactly). > > I can't see why it would fail. > > On Nov 5, 10:32 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > > With simplejson module (that is part of django distribution) you can > covert > > to JSON any python objects. So create data structure you need and pass it > to > > simplejson dump/dumps functions. > > > > On Thu, Nov 6, 2008 at 01:17, Darthmahon <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > Ok I'm using the following code to turn my model into JSON: > > > > > from django.core import serializers > > > json = serializers.serialize("json", Event.objects.all()[:5], > > > fields=('title','date','location')) > > > > > Now, this returns JSON like this: > > > > > [ > > >{ "pk": 1, "model": "events.event", "fields": { > > >"date": "2008-11-04 00:00:00", "location": 1, "title": > > > "Event 1"} > > >}, > > >{ "pk": 2, "model": "events.event", "fields": { > > >"date": "2008-11-04 00:00:00", "location": 1, "title": > > > "Event 2"} > > >}, > > >{ "pk": 3, "model": "events.event", "fields": { > > >"date": "2008-11-05 00:00:00", "location": 1, "title": > > > "Event 3"} > > >}, > > >{ "pk": 4, "model": "events.event", "fields": { > > >"date": "2008-11-05 00:00:00", "location": 1, "title": > > > "Event 4"} > > >}, > > > ] > > > > > But I want it to output like this: > > > > > [ > > >{ 'date' : '2008-11-04 00:00:00', 'dayEvents' : [ > > >{ 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, > > >{ 'title' : 'Event 2', 'location' : '1', 'id' : '2' } > > >]}, > > >{ 'date' : '2008-11-05 00:00:00', 'dayEvents' : [ > > >{ 'title' : 'Event 3', 'location' : '1', 'id' : '3' }, > > >{ 'title' : 'Event 4', 'location' : '1', 'id' : '4' } > > >]} > > > ] > > > > > The main difference is that the events are grouped by date, which > > > makes it easier for me to loop through them the way I want to. > > > > > Any ideas on how to achieve this, been looking in the documentation > > > but nothing in there from what I can see :( > > > > > The event model looks like this: > > > > > title= models.CharField(max_length=200) > > > date = models.DateTimeField() > > > location = models.IntegerField(choices=LOCATION_CHOICES, default=1) > > > > > Cheers, > > > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting a relationship using double underscores
If you have `serverid` field in database so you can add reference with custom column name [1]. For example: server = models.ForeignKey(Server, db-column="serverid") [1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#db-column On Thu, Nov 6, 2008 at 15:10, gv <[EMAIL PROTECTED]> wrote: > > On 6 Nov, 11:56, Daniel Roseman <[EMAIL PROTECTED]> wrote: > > On Nov 6, 10:25 am, gv <[EMAIL PROTECTED]> wrote: > > > > > Well, you don't appear to have any foreign keys linking Backup and > > Server. You'd need something like this in your Backup declaration: > > > > server = models.ForeignKey('Server') > > Thanks - should have added that I have already tried that, but if I do > I get: > OperationalError: (1054, "Unknown column 'backup.server_id' in 'field > list'") > I get this not only in my view, but also in the 'Backup' part of the > Admin. I guess I should stick with the ForeignKey, and try to solve > the Unknown column - problem. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: multi foreign keys and ordering in admin
Try to set meta [1] `ordering` setting [1]: http://docs.djangoproject.com/en/dev/ref/models/options/ On Thu, Nov 6, 2008 at 14:51, MikeKJ <[EMAIL PROTECTED]> wrote: > > Got something like this > > class A(models.Model): >x >class Admin: >x > > class B(models.Model): >a =models.ForeignKey(A) >xxx > > class C(models.Model): >a = models.ForeignKey(A) >x > > classD(models.Model): >a=models.ForeignKey(A) >xx > > > how do I control the ordering of B,C and D please. At the moment it > appears to be random neither in alpha or in order of the classes. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help regarding renaming the uploaded file name in Django.
Django uploading mechanism allow you to add date-bases values to path. See `upload_to` section in [1] [1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield On Thu, Nov 6, 2008 at 15:45, sadeesh Arumugam <[EMAIL PROTECTED]>wrote: > Hi Friends, > > I need a help from you. How to rename the uploaded file name in django. > Example if we upload a file named "a.jpg" at first time, and at next upload > it is uploaded as "a_.jpg", and at the third time "a__.jpg", likewise the > Underscore after the filename is increasing one time for each upload of the > same image. For this i want to make the filename as -mm-dd-h-m-s > (Current timetamp of the system), so that for each upload we will get a > different filename of same image. > > How to rename the uploaded filename in django... > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Having trouble with django-multilingual
Django-multilingual has its own discussion group: http://groups.google.com/group/django-multilingual. Try to ask there. On Thu, Nov 6, 2008 at 18:44, Brandon Taylor <[EMAIL PROTECTED]>wrote: > > Hi Everyone, > > I'm having a hard time getting django-multilingual to work the way I > expect. > > #settings.py > > LANGUAGES = ( >('en', 'English'), >('es', 'Spanish'), > ) > > TEMPLATE_CONTEXT_PROCESSORS = ( >... >'multilingual.context_processors.multilingual', > ) > > MIDDLEWARE_CLASSES = ( >.. >'multilingual.middleware.DefaultLanguageMiddleware', > ) > > #models.py > > from django.db import models > from django.contrib import admin > import multilingual > > > class Widget(models.Model): >name = models.CharField(max_length=50) > >class Translation(multilingual.Translation): >name = models.CharField(max_length=50) > >class Meta: >verbose_name = _('Widget') >verbose_name_plural = _('Widgets') > >def __unicode__(self): >return self.name > > #index.html > > {% for widget in widgets %} > >{{ widget.name }} > > {% endfor %} > > > When I switch my locale in FireFox, widget.name is always English. > What am I doing wrong? I'm trying to follow the documentation as > closely as possible, but obviously I'm missing something. > > Advice appreciated, > Brandon > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logout- Back Button
The is no way to do "redirect to login page, if i hit back button after logout". But what is wrong that user can see non-actual old data? I think it has no matter. On Nov 6, 8:27 pm, jai_python <[EMAIL PROTECTED]> wrote: > Please help me out --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sort querysets by their data attribute values
There is no other way to do this in python/django layer. But you can try to add your temp data in database layer and sort where. On Thu, Nov 6, 2008 at 22:58, dexter <[EMAIL PROTECTED]> wrote: > > I have a queryset which I have looped thru and added a (temporary) > data attribute to each instance. Now I would like to order the > queryset by the value of the data attributes. If I do it like this: > > sorted(queryset, key=lambda x: x.data_attr) > > the queryset turns into a list and I can't use it like a queryset > anymore = not good! > How can i solve this? > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to get the id in an admin template
`example.com` is default Site added by the project setup into sites contrib application [1] [1]: http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites On Fri, Nov 7, 2008 at 00:12, webcomm <[EMAIL PROTECTED]> wrote: > > I don't understand the documentation. I am able to get the "view on > site" link to show, but the URL is wrong. The correct URL for the > instance is... > > http://www.mysite.com/billing/321 > > ...so I tried this... > >def get_absolute_url(self): >return "/billing/%i" % self.id > > ...but when I click the resulting "view on site" link, I'm redirected > to... > > http://example.com/billing/321/ > > I'm not sure where that "example.com" is coming from. I went looking > for it in settings.py and urls.py and don't see it anywhere. > > -Ryan > > > > > > On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote: > > On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from > within an admin template? I want to > > > add a link to view the instance, and I need the id to create that > > > link. Like so... > > > > > View this item > > > > if your Model supplies a get_absolute_url method, then the Admin will > > automatically create a "view on site" link > > on the change detail page. > > See alsohttp:// > docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu... > > > > adi > > > > -- > > Adi J. Sieker mobile: +49 - 178 - 88 5 88 13 > > Freelance developer web:http://www.sieker.info/profile > > SAP-Developer > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting non-related records
Hi, John Try this: Category.objects.exclude(bulletpoint__report=r) On Fri, Nov 7, 2008 at 01:54, John M <[EMAIL PROTECTED]> wrote: > > i have a model at http://dpaste.com/88760/ > > for a particular Report (r), I'd like to get all categories that > aren't in it's bulletpoints. > > For example, If there are four categories: one, two, three, four. > there is a report with bullet points for one and two, how can I get a > list of three and four. > > This allows me to offer a user to add bulletpoints in those > categories. > > I hope this makes sense :P > > John > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Confused about unittests and fixtures
GenericForeignKey and content type application itself look very doubtful for me. If you have a ForeignKey to the ContentType model then you depends on order with ContentType objects creates on syncdb. Because ContentType that references to some model can have different primary key any time you flush database. I've faced this issue than develop some application that has fixtures with ContentType references. Reference brakes when needed ContentType object has illegal primary key. On Fri, Nov 7, 2008 at 02:06, Russell Keith-Magee <[EMAIL PROTECTED]>wrote: > > On Fri, Nov 7, 2008 at 1:00 AM, AndyH <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > I have the following simple test which demonstrates the confusing > > behaviour I'm seeing: > > > > class AvailabilityTestCase(django.test.TestCase): > >fixtures = FIXTURE_LIST > >def setUp(self): > >response = self.client.login(username='testuser', > > password='password') > >self.assertTrue(response) > > > >def test_page(self): > >print Calendar.objects.all() > >print Calendar.objects.all() > > > >def test_page_again(self): > >print Calendar.objects.all() > >print Calendar.objects.all() > > > > When I run this from "manage.py test", it prints out four lists of > > Calendars as expected. However, the second two, are slightly different > > to the first two. As far as I'm aware I'm not doing anything to the > > all() method (or subscribing in to any triggers) that might cause > > this. But even if I was, my understanding is that the fixtures are > > refreshed for each test so they can run independently of each other. > > In my case, which ever order I run these two tests the second set > > always prints different results to the first. > > Assuming that FIXTURE_LIST is correctly defined and references well > formed fixtures, I can't see anything obviously wrong with your > example. You are correct in your understanding that a Django TestCase > will flush the database at the start of each test, so both tests > should have a clean database and be reporting the same results. > > The suggestion that the GenericForeignKey is the source of the problem > is certainly plausible. I'm not aware of any problems serializing > Generic FK's, but they are more complicated and less exercised than > regular keys and fields, so it is certainly a reasonable place to > start looking. > > If you could provide a minimal complete example of this behaviour and > attach it to a new ticket, it would be most helpful. > > Yours, > Russ Magee %-) > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Select a list item by index
The is not way to get list item by variable index with standard django template tags. On Fri, Nov 7, 2008 at 03:52, jago <[EMAIL PROTECTED]> wrote: > > I have a for loop over a list A. > > inside the loop I want to print out the item of list B at the index > 'forloop.counter0' of list A. > > It is really strange. One can select randon items in a list, or the > first item in a list, but I did not find a way to select the list item > by index. > > Am I missing something? > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: getting request.user into a ModelForm?
For example you can use `thread locals` to store there request object On Fri, Nov 7, 2008 at 10:58, Rob Hudson <[EMAIL PROTECTED]> wrote: > > I have the following: > > ## MODELS > > class Category(models.Model): >user = models.ForeignKey(User) >name = models.CharField(max_length=200) > > class Link(models.Model): >user = models.ForeignKey(User) >category = models.ForeignKey(Category) >name = models.CharField(max_length=255) >url = models.URLField(max_length=255) > > ## FORMS > > class CategoryField(forms.Field): >def clean(self, value): >if not value: >raise forms.ValidationError('This field is required.') >try: >category = Category.objects.get(user=???, name=value) >except Category.DoesNotExist: >category = Category(user=???, name=value) >category.save() >return category > > class LinkForm(ModelForm): >category = CategoryField() >class Meta: >model = Link >exclude = ('user', 'url') > > ## VIEWS > > def create(request): >if request.method == 'POST': >form = LinkForm(request.POST) >if form.is_valid(): >link = form.save(commit=False) >link.user = request.user >link.save() >return HttpResponseRedirect(reverse('link_list')) >else: >form = LinkForm() > >return render_to_response( >'links/link_form.html', { >'form': form, >}, >context_instance=RequestContext(request) >) > > What I don't see is a way to get the user up into my field the way I > have things set up. I originally didn't have a user FK on the > Category model but decided I wanted it so that when adding new Links, > the Categories can be filtered by user so each user sees only their > categories. > > I'm stuck here. Any help is much appreciated. > > Thanks, > Rob > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Browser detection in Django
Hey guys, I'm working on a Django application where I'd like to redirect IE6 users to a specific page encouraging them to update their browser. How would be the most efficient way of doing this? Thanks! Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model Inheritance - And Signals
Try to connection handler without `sender` specified. And filter needed models inside it. def my_handler(sender, **kwargs): if not isinstance(sender, CustomModel): return signals.pre_save.connect(my_handler) On Fri, Nov 7, 2008 at 20:03, Vitaly Babiy <[EMAIL PROTECTED]> wrote: > if I define a model called CustomModel and I attach attach a pre_save > signal to it. Is there any way to have that signal be called any time model > that extends CustomModel is being saved has that method saved. > > I know i could do this by overriding the save method on CustomeModel but I > was wondering if there is any way to do it with signals. > > Thanks, > Vitaly Babiy > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: [Newbie] Self referencing models
Did you read the documentation? http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey On Sat, Nov 8, 2008 at 09:58, sunn <[EMAIL PROTECTED]> wrote: > > How do I make a foreign key to self? > > class Page(models.Model): >title = models.CharField(max_length=128) >display = models.CharField(max_length=64) >path = models.CharField(max_length=64) >sortorder = models.IntegerField() >parent = models.OneToOneField(Page) #Will not work neither will >parenttest = models.ForeignKey(Page) #nor >parenttest2 = models.ForeignKey(self) >def __unicode__(self): >return self.display > > any help appreciated! > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: global name 'Image' is not defined
I think you have a typo in this line, May be you write `Image.new` with lowercase "L" not uppercase "I" as first char. On Sun, Nov 9, 2008 at 02:54, Tsinga <[EMAIL PROTECTED]> wrote: > > Hi Djangonauts, > > I need your help > > I am trying to test a view using PIL(Python Imaging Library). This is > the code: > > from django.http import HttpResponse, HttpResponseRedirect > from django.template import Context, RequestContext > from django.template.loader import get_template > from django.http import HttpResponse, Http404 > from django.contrib.auth.models import User > from django.shortcuts import render_to_response > from django.contrib.auth import logout > from example_app.forms import * > from PIL import Image > import random > INK = "red", "blue", "green", "yellow" > > > def main_page(request): >return render_to_response( >'main_page.html', RequestContext(request) >) > > def user_page(request, username): >try: >user = User.objects.get(username=username) >except: >raise Http404('Requested user not found.') > >bookmarks = user.bookmark_set.all() >variables = RequestContext(request, { >'username': username, >'bookmarks': bookmarks >}) >return render_to_response('user_page.html', variables) > > def logout_page(request): >logout(request) >return HttpResponseRedirect('/image/') > > def register_page(request): >if request.method == 'POST': >form = RegistrationForm(request.POST) >if form.is_valid(): >user = User.objects.create_user( >username=form.cleaned_data['username'], >password=form.cleaned_data['password1'], >email=form.cleaned_data['email'] >) >return HttpResponseRedirect('/register/success/') >else: >form = RegistrationForm() >variables = RequestContext(request, { >'form': form >}) >return render_to_response( >'registration/register.html', variables >) > > def image_page(request): >""" create/load image here """ >image = Image.new("RGB", (800, 600), random.choice(INK)) > >""" serialize to HTTP response """ >response = HttpResponse(mimetype="image/png") >image.save(response, "PNG") > >return response > > I am having the following error: > > Traceback: > File "/home/tsinga/webapps/django/lib/python2.5/django/core/handlers/ > base.py" in get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "/home/tsinga/webapps/django/django_example/example_app/views.py" > in image_page > 57. image = Image.new("RGB", (800, 600), random.choice(INK)) > > Exception Type: NameError at /image/ > Exception Value: global name 'Image' is not defined > > Thanks > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Per-Test Caching?
Use database backend for caching while testing. Tests create temporary database so it will have no side effects. On Sun, Nov 9, 2008 at 03:13, Adam Seering <[EMAIL PROTECTED]> wrote: > > Hi, >I have a Django app that relies heavily on caching. I'd like > "./manage.py test" to run on its own test cache instance (so it doesn't > see keys from previous runs / other development / etc). > >I can write code to set up the cache appropriately, but, where can I > put it s.t. it runs before (and, ideally, after, for cleanup purposes) > all test cases? > > Adam > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help! Login() exceeds maximum recursion depth!
Do you have `login` function in this module? On Mon, Nov 10, 2008 at 00:17, nkulmati <[EMAIL PROTECTED]> wrote: > > Hi guys! > > Ok this really pisses me off, because I am using the code directly > from the documentation: > > def my_view(request): >username = request.POST['username'] >password = request.POST['password'] >user = authenticate(username=username, password=password) >if user is not None: >if user.is_active: >login(request, user) ># Redirect to a success page. >else: ># Return a 'disabled account' error message >else: ># Return an 'invalid login' error message. > > > What I get is a RuntimeError with > Exception Value:maximum recursion depth exceeded > > It calls the function login() many many times and then quits with that > error! > Somebody help please! > > Thanks, > Nick. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Interesting result when displaying errors for contrib.auth.forms AuthenticationForm
Please show complete template code On Sun, Nov 9, 2008 at 20:55, Brandon Taylor <[EMAIL PROTECTED]>wrote: > > Hi everyone, > > I'm leveraging auth and have a login form that uses contrib.auth.forms > AuthenticationForm. > > When displaying non-field-specific errors, I get interesting results: > > #template.html > # if form.errors > __all__ > >Please enter a correct username and password. Note that both > fields are case-sensitive. > > > Does anyone know how I can get rid of the __all__ ? > > TIA, > Brandon > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---