Re: Preserving pretty HTML output
Thank you for the detailed response, Malcolm. I wasn't aware of the complexities of the issue and understand better now why it is the way it is. It was something that was really bugging me, but I feel like I can let it go now :) I'm not skilled enough in Python to take a crack at solving the problem myself. Although I'd prefer my HTML source output to look good, I'll take readability of template code (and performance) over rendered output prettiness. Thanks again. --~--~-~--~~~---~--~~ 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: Query API: get all users without a group
Filip Wasilewski schrieb: > On 2 Gru, 16:45, Thomas Guettler <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> I want to get all objects where the corresponding many-to-many field is >> empty. >> >> Example: get all users without a group >> > [...] > > The preferred solution is using the `isnull` filter: > > User.objects.filter(groups__isnull=True) > > It evaluates to a left join of the `auth_user` table with > `auth_user_groups` and a simple `where` statement. > > Thank you! Django ORM is great. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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 create json from template?
thanks V On dec. 3, 07:49, "David Zhou" <[EMAIL PROTECTED]> wrote: > On Wed, Dec 3, 2008 at 1:17 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > To trim last colon wrap it with if statement: > > > {% if forloop.revcounter0 %},{% endif %} > > You can also do: > > {% if not forloop.last %},{% endif %} > > Which, IMO, is slightly more clear. > > --- > David Zhou > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 create and send a pdf attachment
Epinephrine schrieb: > Does anyone have a code sample that shows how to create a pdf document > and then, without saving that document to disk, email it as an > attachment? > > I am using the ReportLab PDF library at the platypus level for pdf > creation. > > For emailing, I expect to use Django's EmailMessage class. > > Hi, looking at the source: django/core/mail.py: def attach(self, filename=None, content=None, mimetype=None): """ Attaches a file with the given filename and content. The filename can be omitted (useful for multipart/alternative messages) and the mimetype is guessed, if not provided. If the first parameter is a MIMEBase subclass it is inserted directly into the resulting message attachments. """ -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
sorting and grouping problem
Hello, i have a sorting and grouping problem: This is the situation: the app i'm working on has to sort cinemas, cinema shows, movies and rooms In a model "Shows" i stored each data about which cinema, which room, what time and which film..so now i have a great number of show objects to sort in order to put them in the template. I need to regroup the shows by room and movie title (they are already sorted by cinema) in order to have something like this: room - title - showtime Room 1 - Whatever movie -- 18:00 - 20.30 - 22:00 Room 2 - SomeOther movie -- 16:00 - 18:30 - 21:00 and so on.. Since i have a single Show object for each showtime (with FKs to the room.id and movietitle.id) how can create a model for the shows with the showtimes sorted out? Right now i'm working like this: 1) i have a custom model defined in the view (so a temporary model just for the purpose) (note: italian words..not a big deal though: spett = short for "spettacolo" which means show, film = movie, titolo = title, regia = director) class Spett(models.Model): id = models.IntegerField() cinema_name = models.CharField() #sala = models.CharField() film_titolo = models.CharField() film_cast = models.CharField() film_regia = models.CharField() orari = models.CharField() def __str__ (self): return '%s' % (self.id) "orari" means "showtimes" and as you can see is a charfield. That's because for each Show object i'd like to take it's str(showtime) (which is a timefield) and append (or rather insert in the 1st position) it to a list, which will be then put in the orari field. Ok so.. to recap.. My problem here is that i don't know how to sort the Show objects by movie because i also have to cycle ("for" iteration) on every object to get the single showtimes (and append them on the showlist) ... Well, maybe it's easier than it looks (or rather: than it seems to me) but now i'm really stuck.. Can someone give me some advice, hint? Any help is really appreciated, thanks! -Davide- PS. i almost forgot: sadly i have to work on a weird db structure, and i can't modify it... --~--~-~--~~~---~--~~ 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: change i18n language through hyperlinks
wow this is dangerous! Changes language settings for all users ;P But I couldnt unerstand how session and cookie frameworks works, documented examples doesn't work... On Dec 3, 6:56 am, Ozgur Odabasi <[EMAIL PROTECTED]> wrote: > try this > > def set_language(request, lang_code): > next = request.REQUEST.get('next', None) > if not next: > next = '/' > response = http.HttpResponseRedirect(next) > if lang_code and check_for_language(lang_code): > settings.LANGUAGE_CODE=lang_code > return response > > On Oct 12, 6:12 am, Chuck22 <[EMAIL PROTECTED]> wrote: > > > thanks Satheesh, the set_language function is partially working for > > me. When I click the lauguage hyperlinks, only the word "Home" works, > > but when I change the msgid to be "Home1", it stop working. It seems > > that "Home" is a django preserved word which get auto-translated. > > > 1. In my base.html, I have > > > {% load i18n %} > > > {% trans "Home1" %} > > > 2. django.po and django.mo files are generated correctly for the > > lauguages. > > > msgid "Home1" > > msgstr "My_Translation" > > > 3. In my settings.py, I have > > > USE_I18N = True > > > LANGUAGE_CODE = 'en-us' > > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.middleware.locale.LocaleMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > ) > > > 4. syncdb is done, and session table is generated. > > > 5. language preferrence selection is like the code below. > > > I don't know which piece is missing. Anyone can suggest? Thanks. > > > On Oct 10, 1:11 am, cschand <[EMAIL PROTECTED]> wrote: > > > > Even then you want in get method you can use the below code. > > > > In view > > > > from django import http > > > from django.utils.translation import check_for_language > > > from django.conf import settings > > > > def set_language(request, lang_code): > > > """ > > > Patched for Get method > > > """ > > > next = request.REQUEST.get('next', None) > > > if not next: > > > next = '/' > > > response = http.HttpResponseRedirect(next) > > > if lang_code and check_for_language(lang_code): > > > if hasattr(request, 'session'): > > > request.session['django_language'] = lang_code > > > else: > > > response.set_cookie(settings.LANGUAGE_COOKIE_NAME, > > > lang_code) > > > return response > > > > And in template > > > > > > > {% for lang in LANGUAGES %} > > > > {{ lang.1 }} > > > > {% endfor %} > > > > > > > > in urls > > > url(r'^setlang/(?P.*)/$', 'utils.views.set_language') > > > > I dont know it is a good practice to do > > > > Satheesh > > > > On Oct 10, 9:30 am, Malcolm Tredinnick <[EMAIL PROTECTED]> > > > wrote: > > > > > On Thu, 2008-10-09 at 23:51 -0400, Chuck Bai2 wrote: > > > > > I want to allow user select language preference through clicking the > > > > > language hyperlinks like "_English_ | _French_" switch. And I also > > > > > want > > > > > to redirect back to the previous page after clicking the language > > > > > switch. Is it possible to use Django view: > > > > > django.views.i18n.set_language? In the documentation, there is an > > > > > example using form submit to select language using this view. > > > > > > > > > > > > > > > > > > > > > {% for lang in LANGUAGES %} > > > > > {{ lang.1 }} > > > > > {% endfor %} > > > > > > > > > > > > > > > > > > > > > But I want to implement this using hyperlinks and want to know how. > > > > > You'll need to write your own view to handle this (you could look at > > > > Django's view for inspiration). Django intentionally doesn't support > > > > this because it's bad practice (using a GET request to initiate a state > > > > change). > > > > > Regards, > > > > Malcolm- 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 -~--~~~~--~~--~--~---
Re: GeoDjango in Ubuntu 8.10, Segmentation Fault
Hi, On Dec 3, 5:21 pm, Andre P LeBlanc <[EMAIL PROTECTED]> wrote: > Confirmed also. only happens on my 64-bit machine, and is not related > to apache at all as I can reproduce it faithfully in ipython. > I tried pretty hard to replicate it in the console and couldn't - none of our unit tests crashed it, and neither would anything else i tried. But the minute it was running under mod-python/mod-wsgi it segfaulted with the simplest method called on a GEOSGeometry object. 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 -~--~~~~--~~--~--~---
Question about i18n
Hello django-users, first post to this list :) I often use the i18n support of Django in my projects, and I have a small annoyance/problem that maybe someone can help me with. If I decide to customize e.g. admin/index.html, by copying it over from django to my project, strings in that template such as "My Actions" will now be treated as untranslated by manage.py makemessages -a, even though they are indeed translated in Django's own django.po. This is all logical and all, and I can see why it is so, but it makes my project's django.po unnecessarily cluttered with "untranslated" strings that I in fact don't have translate, since they are translated in Django's own django.po. Is there any way that I can make the makemessages process take into consideration the django.po from Django itself when deciding whether a string is translated or not? I would not like to exclude my customized template from translation, since there might be strings in it that I actually added myself that should be extracted for translation. Hope the answer isn't glaringly obvious, but I did some googling and searched the list for a solution. Thanks in advance and thanks to the Django devs for an excellent framework. Best regards, Elvis --~--~-~--~~~---~--~~ 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: replacing a contrib class
Use it in the User class place , What I want to avoid is patching the user source code. Is there any way to do this ? Sandro On Dec 2, 7:33 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > I did considered , but I could not see how to do it , the model I want > > to inherit is from > > contrib.Users and the model I want to replace is contrib.Users . > > It looks to me like a circular reference ...?? > > How can I use the inherited model in the model I inherited from ?? > > It's still not clear what you mean by "replacing a model". > > Let's say you derive your class MyUser from the > django.contrib.auth.models.User class like this: > > class MyUser(User): > pass > > What is it that you want to do in the MyUser inherited class now? > > -Rajesh 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Many-to-Many to exists table
Thank you Thomas for your feedback! We need a Many-To-Many Relation not to "group", but to "user_auth_group". I try to draw the desirable result: user --- user_auth_group group | | user_auth_group_area | | area Regards, Dennis --~--~-~--~~~---~--~~ 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: GeoDjango in Ubuntu 8.10, Segmentation Fault
> "The same problem [segfault] could afflict any python package that > uses Ctypes on 64-bit systems without explicitly marking argument and > return types. " > > Looking back through the modwsgi thread and this one, everyone's on > 64bit, except the CentOS guy who said it worked ok on 32bit but not on > 64bit. > > Maybe thats the problem with the ctypes+geos bindings in GeoDjango? > I'm running something-pre-1.0, but I can try it on a trunk checkount > to confirm the same symptoms. I realized the problems about not making explicit argument return types, and made _almost_ all of them explicit over a _year_ ago in r6653 (by adding the `prototypes` directory where all interactions with C functions were defined). Good to see that Shapely got around to eventually doing that, rather than the haphazard fixes they were implementing up to this point that never really addressed the underlying issues. The reason I said "almost" is that I purposely did not do this for routines that return strings allocated within GEOS. If you specified the response type as `c_char_p` then ctypes would convert to a Python object (str) when given to a ctypes error check function. In other words, because I was doing the proper thing and using the error check function it is not possible to set the response type to `c_char_p` _and_ get the pointer address to the string because all you got was a Python str instead. It's important to get the pointer address, otherwise I could not free the string memory allocated inside the GEOS library -- in other words, GeoDjango would leak memory every time one serialized to WKT if I didn't do it this way (that's bad). While it's not possible to get the pointer address when using `c_char_p` as the restype, I've since figured out that if you use a simple _subclass_ of `c_char_p` and use that for the response type I can get access to both the string value and the pointer address to be freed. I've implemented this patch in my minor refactor of the GEOS interface for 1.1 [1]. I've also created a ticket [2] and I'll attach a patch with the fix, which I'll commit to trunk and the 1.0.X branch within a week. And now I realized why I couldn't reproduce on CentOS -- I was using a 32-bit version; forgot to ask "what architecture", d'oh. -Justin [1] http://geodjango.org/hg/gis-geos [2] http://code.djangoproject.com/ticket/9747 --~--~-~--~~~---~--~~ 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: replacing a contrib class
Hi Rajesh, That's the way I did. But I am wondering how I can hide the Users in admin site? Thanks. Logan On Dec 3, 5:33 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > I did considered , but I could not see how to do it , the model I want > > to inherit is from > > contrib.Users and the model I want to replace is contrib.Users . > > It looks to me like a circular reference ...?? > > How can I use the inherited model in the model I inherited from ?? > > It's still not clear what you mean by "replacing a model". > > Let's say you derive your class MyUser from the > django.contrib.auth.models.User class like this: > > class MyUser(User): > pass > > What is it that you want to do in the MyUser inherited class now? > > -Rajesh 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
about tutorial
Hi, so I did the tutorial and did a simple modification in order to get 'polls' views and 'admin' view too but I am failing. It's that: for mysite/urls.py: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), (r'^polls/', include('mysite.polls.urls')), ) But, if so, then admin pages failed (http://localhost:8000/admin/): TemplateSyntaxError at /admin/ Caught an exception while rendering: Tried vote in module mysite.polls.views. Error was: 'module' object has no attribute 'vote' ... If I want 'admin' view, then I have to comment out line "(r'^polls/', include('mysite.polls.urls'))," Well, I must confess that my knowledge on regexp is limited. So, in the end, what should I do about mysite/urls.py in order to get both admin and polls pages working? Many thanks in advance, Alan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django-tagging encoding errors
Guys, I'm in trouble. I'm using the django-tagging application with a Swedish news application. It generally works, but there's one big problem which has taken me forever to solve. I've concluded that the issue lies in the http://django-tagging.googlecode.com/svn/trunk/tagging/models.py file. If you look at the __unicode__ method all the way down in the bottom, it refers to self.object and self.tag. The self.object in my case is an Article object which __unicode__ method returns the the title of the Article in a u'%s' % (self.title) format. The issue is that when this title includes "special" characters (åäö), it breaks in the admin and gives me an error which looks like this: DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128). You passed in () Another strange thing is that it works on my local machine, but not on the live server. The local server runs Python 2.5, whereas the live goes for 2.3. I was suspecting that it had something to do with the Python encoding settings, but everything except for this line works. When I remove the åäö from the titles it works, or if I remove self.object from the Unicode method as well. I'm not too experienced with encodings, but I tried something that I hope could help someone help me with this issue ;) In my Python console locally: >>> s = u'ä' >>> s u'\xe4' And on my live server: >>> s = u'ä' >>> s u'\xc3\xa4' I don't know if that helps anyone, but I sure hope so. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: about tutorial
On 3 déc, 13:22, Alan <[EMAIL PROTECTED]> wrote: > Hi, so I did the tutorial and did a simple modification in order to > get 'polls' views and 'admin' view too but I am failing. > > It's that: > > for mysite/urls.py: > from django.conf.urls.defaults import * > from django.contrib import admin > admin.autodiscover() > urlpatterns = patterns('', > (r'^admin/(.*)', admin.site.root), > (r'^polls/', include('mysite.polls.urls')), > ) > > But, if so, then admin pages failed (http://localhost:8000/admin/): > TemplateSyntaxError at /admin/ > Caught an exception while rendering: Tried vote in module > mysite.polls.views. Error was: 'module' object has no attribute 'vote' > ... > > If I want 'admin' view, then I have to comment out line "(r'^polls/', > include('mysite.polls.urls'))," I strongly suspect an error in either your polls.urls module or your polls.views module. It seems you're trying to access some unexisting symbol of the polls.views module (a view function perhaps ?) named 'vote'. > Well, I must confess that my knowledge on regexp is limited. So, in > the end, what should I do about mysite/urls.py in order to get both > admin and polls pages working? first make sure the whole thing works correctly without the admin part. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ForeignKey value return from web page
I am trying to use ForeignKey data returned from a page and view, and am having trouble. I am missing something fundamental I think. Say I have 2 models class TopModel(models.Model): name = models.CharField(max_length=50) db_type = models.CharField(max_length=1, choices=STATUS_DBS) # and another class with an FK to the above class OtherModel(models.Model): name = models.CharField(max_length=50) topmodel = models.ForeignKey(TopModel) # Form classes for the above are just as follows: class TopModelForm(forms.ModelForm): class Meta: model = TopModel class OtherModel(forms.ModelForm): class Meta: model = OtherModel Anyway, if I go to a page template and view for OtherModel, say the user selects an fk for TopModel in OtherModel, I want to get back the actual fk number , e.g, 3, 10, 1, or whatever from the post dict. I currently do not get a value back for this (or I am calling it the wrong thing or something). I just want the Interger id for the fk that would be in the db). I want to use this type of access several layers deep in cases, and this seems like it should be dirt simple (it would be the old school way), but of course, I am trying to get away from that. I have been looking through the docs and things and just confusing myself more and more. So, can anyone tell me what I am doing wrong or if there is an easy (and efficient) way to do this, or perhaps point me to a piece of actual code that does something similar. Thanks very much, Peter --~--~-~--~~~---~--~~ 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: about tutorial
In fact I found the problem. If I had finished part 4 of the tutorial I would have any issue. Method 'vote' is created there and now everything works fine. Sorry for being hurry. Cheers, Alan On Wed, Dec 3, 2008 at 15:24, bruno desthuilliers < [EMAIL PROTECTED]> wrote: > > On 3 déc, 13:22, Alan <[EMAIL PROTECTED]> wrote: > > Hi, so I did the tutorial and did a simple modification in order to > > get 'polls' views and 'admin' view too but I am failing. > > > > It's that: > > > > for mysite/urls.py: > > from django.conf.urls.defaults import * > > from django.contrib import admin > > admin.autodiscover() > > urlpatterns = patterns('', > > (r'^admin/(.*)', admin.site.root), > > (r'^polls/', include('mysite.polls.urls')), > > ) > > > > But, if so, then admin pages failed (http://localhost:8000/admin/): > > TemplateSyntaxError at /admin/ > > Caught an exception while rendering: Tried vote in module > > mysite.polls.views. Error was: 'module' object has no attribute 'vote' > > ... > > > > If I want 'admin' view, then I have to comment out line "(r'^polls/', > > include('mysite.polls.urls'))," > > I strongly suspect an error in either your polls.urls module or your > polls.views module. It seems you're trying to access some unexisting > symbol of the polls.views module (a view function perhaps ?) named > 'vote'. > > > Well, I must confess that my knowledge on regexp is limited. So, in > > the end, what should I do about mysite/urls.py in order to get both > > admin and polls pages working? > > first make sure the whole thing works correctly without the admin > part. > > > > > -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~-~--~~~---~--~~ 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: replacing a contrib class
On Dec 3, 8:47 am, Logan Chow <[EMAIL PROTECTED]> wrote: > Hi Rajesh, > That's the way I did. > But I am wondering how I can hide the Users in admin site? You can unregister the default User model from the admin: from django.contrib import admin from django.contrib.admin.sites import NotRegistered from django.contrib.auth.models import User try: admin.site.unregister(User) except NotRegistered: pass --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
admin TemplateSyntaxError using Django 1.1
I've been following the tutorial on the Django site, except that I'm inserting the app I'm developing in place of the tutorial app data. I received this error after logging into the admin site. TemplateSyntaxError at /admin/ Caught an exception while rendering: no such table: django_admin_log Original Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\debug.py", line 71, in render_node result = node.render(context) File "C:\Python25\lib\site-packages\django\template\defaulttags.py", line 244, in render if (value and not ifnot) or (ifnot and not value): File "C:\Python25\lib\site-packages\django\db\models\query.py", line 185, in __nonzero__ iter(self).next() File "C:\Python25\lib\site-packages\django\db\models\query.py", line 179, in _result_iter self._fill_cache() File "C:\Python25\lib\site-packages\django\db\models\query.py", line 612, in _fill_cache self._result_cache.append(self._iter.next()) File "C:\Python25\lib\site-packages\django\db\models\query.py", line 269, in iterator for row in self.query.results_iter(): File "C:\Python25\lib\site-packages\django\db\models\sql\query.py", line 206, in results_iter for rows in self.execute_sql(MULTI): File "C:\Python25\lib\site-packages\django\db\models\sql\query.py", line 1700, in execute_sql cursor.execute(sql, params) File "C:\Python25\lib\site-packages\django\db\backends\util.py", line 19, in execute return self.cursor.execute(sql, params) File "C:\Python25\lib\site-packages\django\db\backends \sqlite3\base.py", line 167, in execute return Database.Cursor.execute(self, query, params) OperationalError: no such table: django_admin_log Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: no such table: django_admin_log Original Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\debug.py", line 71, in render_node result = node.render(context) File "C:\Python25\lib\site-packages\django\template\defaulttags.py", line 244, in render if (value and not ifnot) or (ifnot and not value): File "C:\Python25\lib\site-packages\django\db\models\query.py", line 185, in __nonzero__ iter(self).next() File "C:\Python25\lib\site-packages\django\db\models\query.py", line 179, in _result_iter self._fill_cache() File "C:\Python25\lib\site-packages\django\db\models\query.py", line 612, in _fill_cache self._result_cache.append(self._iter.next()) File "C:\Python25\lib\site-packages\django\db\models\query.py", line 269, in iterator for row in self.query.results_iter(): File "C:\Python25\lib\site-packages\django\db\models\sql\query.py", line 206, in results_iter for rows in self.execute_sql(MULTI): File "C:\Python25\lib\site-packages\django\db\models\sql\query.py", line 1700, in execute_sql cursor.execute(sql, params) File "C:\Python25\lib\site-packages\django\db\backends\util.py", line 19, in execute return self.cursor.execute(sql, params) File "C:\Python25\lib\site-packages\django\db\backends \sqlite3\base.py", line 167, in execute return Database.Cursor.execute(self, query, params) OperationalError: no such table: django_admin_log Exception Location: C:\Python25\lib\site-packages\django\template \debug.py in render_node, line 81 Python Executable: C:\Python25\python.exe Python Version: 2.5.2 Python Path: ['C:\\django\\mrbc', 'C:\\Python25\\python25.zip', 'C:\ \Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site- packages'] Server time: Wed, 3 Dec 2008 10:17:28 -0500 Template error In template c:\python25\lib\site-packages\django\contrib\admin \templates\admin\index.html, error at line 57 Caught an exception while rendering: no such table: django_admin_log 47 48 {% endblock %} 49 50 {% block sidebar %} 51 52 53 {% trans 'Recent Actions' %} 54 {% trans 'My Actions' %} 55 {% load log %} 56 {% get_admin_log 10 as admin_log for_user user %} 57 {% if not admin_log %} 58 {% trans 'None available' %} 59 {% else %} 60 61 {% for entry in admin_log %} 62 {% if not entry.is_deletion %}{% endif %}{{ entry.object_repr| escape }}{% if not entry.is_deletion %}{% endif %}{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %} 63 {% endfor %} 64 65 {% endif %} 66 67 --~--~-~--~~~---~--~~ 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=
Authentication session timeout
If I enable session timeouts via settings.SESSION_COOKIE_AGE I get the following when accessing my login/logout page: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 278, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 635, in __call__ return self.application(environ, start_response) File "/usr/lib/python2.5/site-packages/django/core/handlers/ wsgi.py", line 243, in __call__ response = middleware_method(request, response) File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ middleware.py", line 32, in process_response expires_time = time.time() + max_age TypeError: unsupported operand type(s) for +: 'float' and 'str' I've tried clearing my cookies to see if that has any effect, unfortunately it doesn't. If I remove SESSION_COOKIE_AGE then authentication works fine, but obviously, sessions do not time out. I'm using Django 1.0.2 Is this a bug or am I doing something wrong? 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: ForeignKey value return from web page
On Dec 3, 3:25 pm, Peter Bailey <[EMAIL PROTECTED]> wrote: > I am trying to use ForeignKey data returned from a page and view, and > am having trouble. I am missing something fundamental I think. > > Say I have 2 models > > class TopModel(models.Model): > name = models.CharField(max_length=50) > db_type = models.CharField(max_length=1, choices=STATUS_DBS) > > # and another class with an FK to the above > > class OtherModel(models.Model): > name = models.CharField(max_length=50) > topmodel = models.ForeignKey(TopModel) > > # Form classes for the above are just as follows: > > class TopModelForm(forms.ModelForm): > > class Meta: > model = TopModel > > class OtherModel(forms.ModelForm): > > class Meta: > model = OtherModel > > Anyway, if I go to a page template and view for OtherModel, say the > user selects an fk for TopModel in OtherModel, > I want to get back the actual fk number , e.g, 3, 10, 1, or whatever > from the post dict. I currently do not get a value back for this (or > I am calling it the wrong thing or something). > > I just want the Interger id for the fk that would be in the db). I > want to use this type of access several layers deep in cases, > and this seems like it should be dirt simple (it would be the old > school way), but of course, I am trying to get away from that. > > I have been looking through the docs and things and just confusing > myself > more and more. > > So, can anyone tell me what I am doing wrong or if there is an easy > (and efficient) way to do this, or perhaps point me to a piece of > actual code that does something similar. > > Thanks very much, > > Peter Sorry, I'm not able to understand what your issue is. What do you mean by 'going to a page template' and 'getting back' an FK? I think you need to explain your use case a bit more. A ModelForm is basically for editing and creating instances of a model. Are you trying to use it for navigation? Maybe an example of your view might help. -- 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: admin TemplateSyntaxError using Django 1.1
On Dec 3, 4:12 pm, JonathanB <[EMAIL PROTECTED]> wrote: > I've been following the tutorial on the Django site, except that I'm > inserting the app I'm developing in place of the tutorial app data. I > received this error after logging into the admin site. > > TemplateSyntaxError at /admin/ > Caught an exception while rendering: no such table: django_admin_log You need to run ./manage.py syncdb after adding contrib.admin to your INSTALLED_APPS. -- 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: Preserving pretty HTML output
You may also want to look at BeautifulSoup. It is an html parser writter for python. It has a method called soup.prettify() in which "soup" is a string of html. prettify() outputs cleanly formatted html. Approximation: soup = "titlehello world" soup.pretiffy() >>> title hello world I hope this helps. On Dec 3, 3:00 am, Tonne <[EMAIL PROTECTED]> wrote: > Thank you for the detailed response, Malcolm. I wasn't aware of the > complexities of the issue and understand better now why it is the way > it is. It was something that was really bugging me, but I feel like I > can let it go now :) > > I'm not skilled enough in Python to take a crack at solving the > problem myself. Although I'd prefer my HTML source output to look > good, I'll take readability of template code (and performance) over > rendered output prettiness. > > Thanks again. --~--~-~--~~~---~--~~ 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: replacing a contrib class
Thanks a lot, Rajesh. Excuse me, but one more question: When I edit/add the inherited class (for example: Student), everything goes well but the password field. It is not user friendly. So I try the following: from django.contrib.auth.admin import UserAdmin admin.site.register(Student, UserAdmin) Then I try to add a new user again. It first shows a form request for username and password (twice), after I fill them up and click on save. An error come with "Student object with primary key u'7' does not exist." I found that, the new user has been created in admin/Users, but not in Student. Logan On Dec 4, 12:04 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On Dec 3, 8:47 am, Logan Chow <[EMAIL PROTECTED]> wrote: > > > Hi Rajesh, > > That's the way I did. > > But I am wondering how I can hide the Users in admin site? > > You can unregister the default User model from the admin: > > from django.contrib import admin > from django.contrib.admin.sites import NotRegistered > from django.contrib.auth.models import User > try: > admin.site.unregister(User) > except NotRegistered: > pass --~--~-~--~~~---~--~~ 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: Non-displayed fields on admin form get overwritten
On Dec 2, 10:03 pm, borntonetwork <[EMAIL PROTECTED]> wrote: > Thank you for your reply, Rajesh. The two fields in question are > actually "pending_referrer_name" and "pending_referrer_email". In the > admin class code below, I include them in the fields attribute. > However, initially I did not and that is when the problem would occur. > And the admin code: > > class Admin: > fields = (('Service provider information', {'fields': You need to use the fieldsets attribute and not the fields attribute here. Can you review your code snippet and include or dpaste the code that actually fails to work? -Rajesh 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin TemplateSyntaxError using Django 1.1
Oh! Duh... I must have missed that part in the 5 or 10 time I read through the tutorial. Funny what you don't see when you're not looking for it. Thanks! On Dec 3, 11:25 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Dec 3, 4:12 pm, JonathanB <[EMAIL PROTECTED]> wrote: > > > I've been following the tutorial on the Django site, except that I'm > > inserting the app I'm developing in place of the tutorial app data. I > > received this error after logging into the admin site. > > > TemplateSyntaxError at /admin/ > > Caught an exception while rendering: no such table: django_admin_log > > You need to run ./manage.py syncdb after adding contrib.admin to your > INSTALLED_APPS. > -- > 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: ForeignKey value return from web page
Sorry for babbling Daniel :-) , my use of all this terminology is still growing (I hope). Anyway, I sorted it out thanks to your brief description above. Trying to do too much twisting and turning lol. Cheers On Dec 3, 11:24 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Dec 3, 3:25 pm, Peter Bailey <[EMAIL PROTECTED]> wrote: > > > > > I am trying to use ForeignKey data returned from a page and view, and > > am having trouble. I am missing something fundamental I think. > > > Say I have 2 models > > > class TopModel(models.Model): > > name = models.CharField(max_length=50) > > db_type = models.CharField(max_length=1, choices=STATUS_DBS) > > > # and another class with an FK to the above > > > class OtherModel(models.Model): > > name = models.CharField(max_length=50) > > topmodel = models.ForeignKey(TopModel) > > > # Form classes for the above are just as follows: > > > class TopModelForm(forms.ModelForm): > > > class Meta: > > model = TopModel > > > class OtherModel(forms.ModelForm): > > > class Meta: > > model = OtherModel > > > Anyway, if I go to a page template and view for OtherModel, say the > > user selects an fk for TopModel in OtherModel, > > I want to get back the actual fk number , e.g, 3, 10, 1, or whatever > > from the post dict. I currently do not get a value back for this (or > > I am calling it the wrong thing or something). > > > I just want the Interger id for the fk that would be in the db). I > > want to use this type of access several layers deep in cases, > > and this seems like it should be dirt simple (it would be the old > > school way), but of course, I am trying to get away from that. > > > I have been looking through the docs and things and just confusing > > myself > > more and more. > > > So, can anyone tell me what I am doing wrong or if there is an easy > > (and efficient) way to do this, or perhaps point me to a piece of > > actual code that does something similar. > > > Thanks very much, > > > Peter > > Sorry, I'm not able to understand what your issue is. What do you mean > by 'going to a page template' and 'getting back' an FK? > > I think you need to explain your use case a bit more. A ModelForm is > basically for editing and creating instances of a model. Are you > trying to use it for navigation? Maybe an example of your view might > help. > -- > 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: replacing a contrib class
On Dec 3, 11:37 am, Logan Chow <[EMAIL PROTECTED]> wrote: > Thanks a lot, Rajesh. > Excuse me, but one more question: > When I edit/add the inherited class (for example: Student), > everything goes well but the password field. It is not user friendly. > So I try the following: > > from django.contrib.auth.admin import UserAdmin > admin.site.register(Student, UserAdmin) > > Then I try to add a new user again. It first shows a form request for > username and password (twice), after I fill them up and click on save. > An error come with "Student object with primary key u'7' does not > exist." > I found that, the new user has been created in admin/Users, but not in > Student. The built-in UserAdmin has special code that deals with the password encryption flow for a new user account. Take a look at the code in /django/contrib/auth/admin.py. You will probably want to extend the UserAdmin class there with your own "StudentAdmin" class. You should also look at the add_form parameter there which uses a special form for the "Add User" action. You may have to extend that form as well. At this point, you should also consider simply copying over the entire django.contrib.auth.* code hierarchy into your own custom app and making your necessary extensions directly to those models instead of using the contrib.auth built-in application. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Disappearing inline in admin
Very strange. This is the admin for the model: from django.contrib import admin from articles.models import * class SectionInline(admin.StackedInline): model = section class ArticleAdmin(admin.ModelAdmin): model=Article filter_horizontal = ('related_articles',) prepopulated_fields = {'slug': ('title',)} search_fields = ['author__username','main_section','title'] list_display = ('title', 'author','slug', 'created','issue','publication',) list_filter = ('created','last_modified','sites','publication',) radio_fields = {'publication': admin.VERTICAL} inlines = [ SectionInline, ] admin.site.register(Article, ArticleAdmin) Pretty straightforward. Only thing unusual I'm seeing is that I didn't capitalize the Section class (it's not capped in the model, either). When I go to Article, the sections are there, inline, as they should be. When I SAVE, all the sections disappear. Suggestions? --~--~-~--~~~---~--~~ 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: admin css, is this still supported?
Thanks Malcom, I'll do what I can On Dec 2, 8:05 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-12-02 at 08:21 -0800, John M wrote: > > I've searched for theadminCSSguide, and found it deprecated (http:// > > docs.djangoproject.com/en/dev/obsolete/admin-css/?from=olddocs), is > > there a replacement? > > You can still customise theadminCSS. I suspect it just hasn't been > documented for the neweradminyet. But you'll see a bunch of .cssfiles > in the django/contrib/admin/media/css/ directory and, if all else fails, > poking around with something like Firebug will show the relevant classes > fairly quickly. > > If you are playing around in that area, take notes as you go and you > might be able to help us resurrect the old documentation and make it > appropriate for the newadmin. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Webservers, Django thread-safeness, etc.
Deploying Django behind Apache is great for real web apps, but I also use Django for Desktop apps that employ a web browser as the UI. In this situation, a distribution package that depends on Apache is not an option (too much for end users to manage), and the Django development server's weaknesses (especially the one request at a time limitation) disqualify it. I've had positive experiences with the standalone CherryPy webserver in other contexts, and I've seen it recommended for use with Django, BUT I'm having problems. Maybe once in every dozen page requests (each which might result in a dozen or more http requests) it appears that the CherryPy webserver loses the request, i.e. it never gets passed up the WSGI stack to Django. If I hit the browser's reload button, (usually) the resubmitted page request is handled OK. Although I can't prove it, I'm suspicious that the problem may be that Django is not thread safe. Can anyone state for a fact that it is safe to use Django with a multi-threaded webserver? If not, then multi- threaded webservers like the CherryPy server are not really candidates for use with Django. Is there a high quality, server that's light enough to be packaged with a desktop app or other turn-key app that has been vetted for use with Django? I've researched the python based servers I could find mentioned via Google search, but everything I've found is either unmaintained, multi-threaded, or severely crippled. 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: Disappearing inline in admin
On Dec 3, 10:49 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > When I go to Article, the sections are there, inline, as they should > be. When I SAVE, all the sections disappear. Suggestions? Turns out there was a unicode error in the inline. Maybe it will help someone else somewhere down the line. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Weird Windows issue
Hi, I am fairly new to python and I am trying to get django running propertly. if I type django-admin.py startproject mysite I keep getting the following message. Type 'django-admin.py help' for usage. whereas if I type django-admin.pyc startproject mysite , it works. I have looked at the file associates and my .py is pointing to python25 whereas .pyc is pointing to python. Is this the problem and if so, how do I change this on Vista. Everytime I change program and point it to python, it doesn't take the association. I am running activeState python 2.5 Regards --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Possible to use raw_admin_fields with inlineformset_factory for a create page?
Hi folks, I am a newforms newbie who is currently porting a .96 project over to 1.0 I have been trying to coerce the examples in the Django documentation to accommodate creating a "Document" . I have three models: Document, DocPart --> These are in the doc module. DocPart is an intermediary Part --> This is in the ipl module. There are hundreds of thousands of parts. <><><><><><><><><><> Simplified models -- class Document(models.Model): number = models.CharField(max_length=30) title = models.CharField(max_length=30) class DocPart(models.Model): part = models.ForeignKey(mysite.ipl.models.Part) document = models.ForeignKey(Document) # in mysite.ipl.models class Part(models.Model): number = models.CharField(max_length=30) description = models.CharField(max_length=30) <><><><><><><><><> Forms - DocumentForm(ModelForm): class Meta: model = Document <><><><><><><><><><><> If the user visits the document create page for the first time, in the view I use: form = DocumentForm() DocPartFormset = inlineformset_factory(Document, DocPart) formset = DocPartFormset() . . . return render_to_response('document_form.html','form':form, 'formset':formset) <><><><><><><><><><><> As expected the page takes a very long time to load since each select for the DocPart is filled with hundreds of thousands of part numbers. Since the raw_id_admin has been separated out of the model in 1.0 how do I get the inlineformset_factory to understand that I want to use raw_admin_field for part? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
More User/Profile troubles
Hi all, I have another newbie question. The user registration + profiles seems to always be giving me a lot of trouble, I think Im nearly there but Im sort of stuck at the moment and not sure how to proceed. I am having trouble setting a user profile that is hooked up to the user all in one page. Ive set up a custom profile for my users, here is the model with a form- class CustomProfile(models.Model): user = models.ForeignKey(User, unique=True) GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) birthday = models.DateField() country = models.CharField(max_length=50) class CustomProfileForm(ModelForm): class Meta: model = CustomProfile fields = ('gender', 'birthday', 'country') And here is my view for my signup page - def signup(request): if request.method == 'POST': form = UserCreationForm(request.POST) extraform = CustomProfileForm(request.POST) if form.is_valid(): form.save() extraform.save() return HttpResponseRedirect("/") else: form = UserCreationForm() extraform = CustomProfileForm() return render_to_response('signup.html', { 'form': form, 'extraform': extraform }) This view doesnt work because it is not saving 'user' in CustomProfileForm. Ok now the problem I am having is with the foreignkey in the custom profile model, and successfully linking that to the User. I imagine I could do it easily with two web pages - I would make a usercreationform on one page and then direct to a page to customise a profile, but I am trying to do it all at once. I have to save 'form' first, to be able to save 'extraform', but then I dont know how to set the user setting in extraform to the one ive just created. All my configurations seem to fail. I hope I havent made this too confusing, am I on the right track at least? Any help Would be great! Phil --~--~-~--~~~---~--~~ 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: Webservers, Django thread-safeness, etc.
On Wed, Dec 3, 2008 at 11:45 AM, SteveB <[EMAIL PROTECTED]> wrote: > I've had positive experiences with the standalone CherryPy webserver > Although I can't prove it, I'm suspicious that the problem may be that > Django is not thread safe. Can anyone state for a fact that it is > safe to use Django with a multi-threaded webserver? If not, then multi- > threaded webservers like the CherryPy server are not really candidates > for use with Django. No-one can state this for a fact because, even though many people (and this is where I remind everyone that it's often a good idea to search the archives before posting, especially for frequently-asked questions like this one) use Django with thread- as opposed to process-based server solutions without reporting thread-safety issues, it's simply impossible to state, unequivocally, that "everything you will ever do involving Django will be 100% thread safe". This should, incidentally, be fairly clear from the fact that Django offers you numerous ways to work with, e.g., mutable stateful objects, such that Django itself doesn't do anything unsafe with them, but you (and by implication, your code) quite easily can if you're not careful. In other words, the answer is "to the best of anyone's knowledge, Django does not have issues running in threaded servers, and if/when bugs are found which contradict that we fix them". But there isn't and never will be a categorical assurance that Django is provably 100% threadsafe or that there won't from time to time be a bug that needs to be fixed. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: More User/Profile troubles
On Dec 3, 12:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > ... > And here is my view for my signup page - > > def signup(request): > if request.method == 'POST': > form = UserCreationForm(request.POST) > extraform = CustomProfileForm(request.POST) > if form.is_valid(): > form.save() > extraform.save() > return HttpResponseRedirect("/") > else: > form = UserCreationForm() > extraform = CustomProfileForm() > > return render_to_response('signup.html', { > 'form': form, > 'extraform': extraform > }) > > This view doesnt work because it is not saving 'user' in > CustomProfileForm. > > Ok now the problem I am having is with the foreignkey in the custom > profile model, and successfully linking that to the User. Yes. You need to set the user foreign key inside the extraform before you save it. See the discussion here about ModelForms save() with commit=False: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method --~--~-~--~~~---~--~~ 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: django table locking
On Nov 18, 7:46 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Django doesn't do any explicit table locking, although there are > transactions involved. However, that shouldn't be affecting this. So Django is not safe to use in a concurrent environment? Well, it is if you don't mind two users stepping on one another's changes, which you would have to prevent with explicit, optimistic locking, I assume? > You just say "read locks", but that isn't a defined postgreSQL lock Sorry, my tables looked like this: relname | relation | database | transaction | pid | mode | granted -+--+--+-+--- +-+- pg_class| 1259 |17456 | | 12221 | AccessShareLock | t adminevents |17818 |17456 | | 31151 | AccessShareLock | t clients |17618 |17456 | | 10325 | AccessExclusiveLock | f clusternode |17759 |17456 | | 31151 | AccessShareLock | t pg_locks|16759 |17456 | | 12221 | AccessShareLock | t clients |17618 |17456 | | 31151 | AccessShareLock | t cluster |17746 |17456 | | 31151 | AccessShareLock | t So one process was waiting to acquire an AccessExclusiveLock, and there was already an AccessShareLock on it (the clients table). Mike --~--~-~--~~~---~--~~ 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: django-tagging encoding errors
On Wed, Dec 3, 2008 at 10:14 AM, Alex Jonsson <[EMAIL PROTECTED]>wrote: > > Guys, I'm in trouble. > > I'm using the django-tagging application with a Swedish news > application. It generally works, but there's one big problem which has > taken me forever to solve. > > I've concluded that the issue lies in the > http://django-tagging.googlecode.com/svn/trunk/tagging/models.py file. > If you look at the __unicode__ method all the way down in the bottom, > it refers to self.object and self.tag. The self.object in my case is > an Article object which __unicode__ method returns the the title of > the Article in a u'%s' % (self.title) format. > > The issue is that when this title includes "special" characters (åäö), > it breaks in the admin and gives me an error which looks like this: > > DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in > position 0: ordinal not in range(128). You passed in Unicode data]> () > > Another strange thing is that it works on my local machine, but not on > the live server. The local server runs Python 2.5, whereas the live > goes for 2.3. > I think you are hitting a Python 2.3 unicode bug. Something like: u'%s' % obj should call obj's unicode method, if it exists. However in Python 2.3 obj's str method is called instead. The common workaround for this is to write instead: u'%s' % unicode(obj) It sounds like one or more of the django-tagging model __unicode__ methods needs to employ this workaround in order to work properly under Python 2.3. Karen --~--~-~--~~~---~--~~ 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: Authentication session timeout
On Wed, Dec 3, 2008 at 11:09 AM, mdp <[EMAIL PROTECTED]> wrote: > > If I enable session timeouts via settings.SESSION_COOKIE_AGE I get the > following when accessing my login/logout page: > > Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > basehttp.py", line 278, in run >self.result = application(self.environ, self.start_response) > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > basehttp.py", line 635, in __call__ >return self.application(environ, start_response) > > File "/usr/lib/python2.5/site-packages/django/core/handlers/ > wsgi.py", line 243, in __call__ >response = middleware_method(request, response) > > File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ > middleware.py", line 32, in process_response >expires_time = time.time() + max_age > > TypeError: unsupported operand type(s) for +: 'float' and 'str' > > I've tried clearing my cookies to see if that has any effect, > unfortunately it doesn't. If I remove SESSION_COOKIE_AGE then > authentication works fine, but obviously, sessions do not time out. > > I'm using Django 1.0.2 > > Is this a bug or am I doing something wrong? > > What did you set SESSION_COOKIE_AGE to? It rather sounds like you set it to a string value when a numeric is expected. Karen --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
Hey there, I am trying to figure out how to solve this: I have created a new model called GroupLevels to extend the already existing Group model by django.contrib.auth.models.group. I wish to have the GroupLevels inline with the Group Model in the admin panel. I have attempted to do this via: class GroupLevels(models.Model): group = models.ForeignKey(Group, unique=True) shows = models.PositiveIntegerField(default=0) items = models.PositiveIntegerField(default=0) class Meta: verbose_name_plural = "Group Permissions" verbose_name = "Group Permission" def __unicode__(self): return self.group.name class GroupInline(admin.TabularInline): model = Group class GroupAdmin(admin.ModelAdmin): inlines = [GroupInline,] admin.site.register(Group, GroupAdmin) However i get an error saying that there is no foreign key from Group to GroupLevels. What am i doing wrong here? How do i get them to display inline in the admin? Thanks alot for any advice! --~--~-~--~~~---~--~~ 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 delete template fragment cache?
On Dec 3, 12:37 am, Bartek SQ9MEV <[EMAIL PROTECTED]> wrote: > I know I should use cache.delete('a'), but how can I get key for > particular fragment? The key is 'fragment_name:additional:arguments:seperated:by:colons'. > What is better idea? Use signals (I do not know too mouch about them > yet)or just overwrite model_save method? It doesn't really matter. Signals are most useful, IMO, for tying behavior to events that happen in apps you don't control (3rd-party, contrib, etc.). --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
On Wed, Dec 3, 2008 at 2:29 PM, VoiDeT <[EMAIL PROTECTED]> wrote: > > Hey there, > > I am trying to figure out how to solve this: > I have created a new model called GroupLevels to extend the already > existing Group model by django.contrib.auth.models.group. I wish to > have the GroupLevels inline with the Group Model in the admin panel. I > have attempted to do this via: > > class GroupLevels(models.Model): >group = models.ForeignKey(Group, unique=True) >shows = models.PositiveIntegerField(default=0) >items = models.PositiveIntegerField(default=0) > >class Meta: >verbose_name_plural = "Group Permissions" >verbose_name = "Group Permission" > >def __unicode__(self): >return self.group.name > > class GroupInline(admin.TabularInline): >model = Group > I think you want to specify the model as GroupLevels -- isn't that what you want to be inline? > > class GroupAdmin(admin.ModelAdmin): >inlines = [GroupInline,] > > admin.site.register(Group, GroupAdmin) > > However i get an error saying that there is no foreign key from Group > to GroupLevels. What am i doing wrong here? How do i get them to > display inline in the admin? > I don't see GroupLevels mentioned at all in what you posted for the admin, so I'm a bit confused by the error message you are reporting. But it sounds like you have things specified backwards in terms of what's inline with what. Karen --~--~-~--~~~---~--~~ 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: GeoDjango in Ubuntu 8.10, Segmentation Fault
I had a large table of zip & postal codes which always crashed after about 20 minutes of geocoding them in the ipython shell, i did the same thing several times on the same os, but on a 32-bit machine with no issues. running under mod-python or mod-wsgi on the 64-bit box also seems to randomly throw 500's, but not in any consistent way. On Dec 3, 5:06 am, rcoup <[EMAIL PROTECTED]> wrote: > Hi, > > On Dec 3, 5:21 pm, Andre P LeBlanc <[EMAIL PROTECTED]> wrote: > > > Confirmed also. only happens on my 64-bit machine, and is not related > > to apache at all as I can reproduce it faithfully in ipython. > > I tried pretty hard to replicate it in the console and couldn't - none > of our unit tests crashed it, and neither would anything else i tried. > But the minute it was running under mod-python/mod-wsgi it segfaulted > with the simplest method called on a GEOSGeometry object. > > 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 -~--~~~~--~~--~--~---
Re: Adding Model Inline with Group Model
Hi Karen, Thanks alot for your quick reply! Indeed the admin.site.register(Group, GroupAdmin) was meant to write as admin.site.register(GroupLevels, GroupAdmin). However when i do this it doesn't display it inline, instead merely throws back an error saying Group doesn't have a foreignkey to GroupLevels. So what i have above is trying to link GroupLevels inline with the Group model, or no? What am i missing here? Thanks alot --~--~-~--~~~---~--~~ 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 create and send a pdf attachment
Thanks. That is the outline of what I want to do; what I need now is specifics: how to create the document and pass it successfully (MIME, etc) to the attach method. On Dec 3, 12:59 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Epinephrine schrieb:> Does anyone have a code sample that shows how to create > apdfdocument > > and then, without saving that document to disk,emailit as an > > attachment? > > > I am using the ReportLabPDFlibrary at the platypus level forpdf > > creation. > > > For emailing, I expect to use Django's EmailMessage class. > > Hi, > > looking at the source: > > django/core/mail.py: > > def attach(self, filename=None, content=None, mimetype=None): > """ > Attaches a file with the given filename and content. The > filename can > be omitted (useful for multipart/alternative messages) and the > mimetype > is guessed, if not provided. > > If the first parameter is a MIMEBase subclass it is inserted > directly > into the resulting message attachments. > """ > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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: forms and modelform
Buddy, I found this, you might give it a try. http://www.djangosnippets.org/snippets/703/ Graham On Nov 28, 9:59 am, Buddy <[EMAIL PROTECTED]> wrote: > Yes, I try it before to my ask here. I get error if use likethis > (class B(forms.ModelForm, A): > > ### > TypeError at /A/ > > Error when calling the metaclass bases > metaclass conflict: the metaclass of a derived class must be a > (non-strict) subclass of the metaclasses of all its bases > > Request Method: GET > Request URL: http://127.0.0.1:8000/A/ > Exception Type: TypeError > Exception Value: > > Error when calling the metaclass bases > metaclass conflict: the metaclass of a derived class must be a > (non-strict) subclass of the metaclasses of all its bases > # > > On 28 нояб, 18:39, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > On Nov 28, 3:47 pm, Buddy <[EMAIL PROTECTED]> wrote: > > > > I have model: > > > > class A(forms.Form): > > > p1 = forms.CharField() > > > p2 = forms.CharField() > > > > class B(A): > > > class Meta: > > > model = User > > > fields = ('username', 'email', 'first_name', 'last_name',) > > > >http://dpaste.com/94378/ > > > > but fields that define in class B not apears when I render it in html. > > > Why is it not apears? > > > Because neither A nor B are ModelForms. You could make B inherit from > > both ModelForm and A - untested, but should work: > > > class B(forms.ModelForm, A): > > ... etc > > > > PS > > > Whether exist class'' tree in any a form for common observe? > > > Sorry, no idea what you're asking here. > > > -- > > 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: django-tagging encoding errors
Karen, I thank you a million times over. You have no idea how many hours I've spent on this issue. :) I got it working by using exactly the method you specified. Finally I'll be able to get some sleep at night! Take care, Alex On Dec 3, 8:18 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Dec 3, 2008 at 10:14 AM, Alex Jonsson <[EMAIL PROTECTED]>wrote: > > > > > > > > > Guys, I'm in trouble. > > > I'm using the django-tagging application with a Swedish news > > application. It generally works, but there's one big problem which has > > taken me forever to solve. > > > I've concluded that the issue lies in the > >http://django-tagging.googlecode.com/svn/trunk/tagging/models.pyfile. > > If you look at the __unicode__ method all the way down in the bottom, > > it refers to self.object and self.tag. The self.object in my case is > > an Article object which __unicode__ method returns the the title of > > the Article in a u'%s' % (self.title) format. > > > The issue is that when this title includes "special" characters (åäö), > > it breaks in the admin and gives me an error which looks like this: > > > DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in > > position 0: ordinal not in range(128). You passed in > Unicode data]> () > > > Another strange thing is that it works on my local machine, but not on > > the live server. The local server runs Python 2.5, whereas the live > > goes for 2.3. > > I think you are hitting a Python 2.3 unicode bug. Something like: > > u'%s' % obj > > should call obj's unicode method, if it exists. However in Python 2.3 obj's > str method is called instead. The common workaround for this is to write > instead: > > u'%s' % unicode(obj) > > It sounds like one or more of the django-tagging model __unicode__ methods > needs to employ this workaround in order to work properly under Python 2.3. > > Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HttpResponse.set_cookie defaults?
>From the documentation it's not obivous what the defaults are for the set_cookie() function. http://docs.djangoproject.com/en/dev/ref/request-response/?from=olddocs#django.http.HttpResponse.set_cookie I've read about the various django SESSION_COOKIE_* settings: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#session-cookie-domain Does set_cookie use these settings as defaults? Or do I need to pass them in? Thanks, 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 -~--~~~~--~~--~--~---
open source project management app that uses django?
Hi everyone, I would like to create a django project managment web app to be used internally in my company. I am a software developer, but have little experience with web apps other than my recent work going through the sams django tutorial book. I'm wondering if anyone knows of any open source/free django web app that I might be able to use to get started on this project. Let me describe the usage model to give you an idea of what I'm aiming for. At a very high level, the usage model for this web app is that a "manager" assigns tasks to "employees" on a weekly basis. Associated with each task is a set of measurements that must be performed by the employee as he/she does the task. The measurements vary based on the task, and somemes the measurement is reported with a comment string, sometimes a number, or sometimes a check mark in one of 'n' radio boxes. As the employees complete the tasks, they fill in the measurements. At the end of the week, the manager can look at each task and review the resulting measurements, and based on that data, decide the next weeks' tasks. Unlike a project mangament tool like MS Project, which helps you schedule and gannt chart the schedule, this is really a tool to for enhancing project communication. It is intended to allow the manager to easily communicate tasks to the employees, get the results back, and then make decisions about what the next set of tasks sould be. All without having to spend a lot of time emailing and talking to people. In the environement where it will be used, the manager is getting results back from maybe 100 different employees, each of which have a few tasks to do. The data is not complex, but there is just too much of it to manage without a tool. Currently folks are using wiki and excel, but in my opninion this is not really automated enough. My thought is that a django web client could provide a very simple and easy to use interface, and could also be extended to get all sorts of nice long term trend information. For exmaple, t would be interesting to know if a project being run at site A executes task 'foo' more frequently or for longer periods of time than a project being run at site B. As data is across multiple similar projects, it seems that it could be mined for lots of interesting info to help improve the productivity of future projects. Ok - so hopefully you get the idea. Now for my questions: * Does anyone know of existing web apps (django or otherwise) like that already exists? * Does this sound like something that would be good to do in Django? * Does anyone know of any free/open source software (django based) that I could use as a starting point? Not being a web developer, I know that if I do this from scratch, I will probably not do a great job. No doubt there are a ton of intracacies to window layout, the structure of the models, the html templates, and other things I haven't even thought of. So I'm thinking it would be great to bootstrap from some existing code, even if it doesn't do quite what I want. I would be happy to contribute my own work back to the open source community. Thanks for any ideas! Margie --~--~-~--~~~---~--~~ 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: Webservers, Django thread-safeness, etc.
On Dec 4, 5:25 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Wed, Dec 3, 2008 at 11:45 AM, SteveB <[EMAIL PROTECTED]> wrote: > > I've had positive experiences with the standalone CherryPy webserver > > Although I can't prove it, I'm suspicious that the problem may be that > > Django is not thread safe. Can anyone state for a fact that it is > > safe to use Django with a multi-threaded webserver? If not, then multi- > > threaded webservers like the CherryPy server are not really candidates > > for use with Django. > > No-one can state this for a fact because, even though many people (and > this is where I remind everyone that it's often a good idea to search > the archives before posting, especially for frequently-asked questions > like this one) use Django with thread- as opposed to process-based > server solutions without reporting thread-safety issues, it's simply > impossible to state, unequivocally, that "everything you will ever do > involving Django will be 100% thread safe". This should, incidentally, > be fairly clear from the fact that Django offers you numerous ways to > work with, e.g., mutable stateful objects, such that Django itself > doesn't do anything unsafe with them, but you (and by implication, > your code) quite easily can if you're not careful. > > In other words, the answer is "to the best of anyone's knowledge, > Django does not have issues running in threaded servers, and if/when > bugs are found which contradict that we fix them". But there isn't and > never will be a categorical assurance that Django is provably 100% > threadsafe or that there won't from time to time be a bug that needs > to be fixed. It should also be stated that your best bet is to use Django 1.0 or later. There were bigger questions marks over older Django versions, with some changes being made for Django 1.0 to address potential threading issues. Graham --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
On Wed, Dec 3, 2008 at 2:46 PM, VoiDeT <[EMAIL PROTECTED]> wrote: > > Hi Karen, > > Thanks alot for your quick reply! > Indeed the admin.site.register(Group, GroupAdmin) was meant to write > as admin.site.register(GroupLevels, GroupAdmin). However when i do > this it doesn't display it inline, instead merely throws back an error > saying Group doesn't have a foreignkey to GroupLevels. > > So what i have above is trying to link GroupLevels inline with the > Group model, or no? > > What am i missing here? I think you've got things backwards in terms of what should be specified as Inline and what should be registered. You're trying to inline Groups in GroupLevels, but your models as specified support inlining GroupLevels in Groups: class GroupLevelsInline(admin.TabularInline): model = GroupLevels class GroupAdmin(admin.ModelAdmin): inlines = [GroupLevelsInline,] admin.site.register(Group, GroupAdmin) Karen --~--~-~--~~~---~--~~ 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: django-tagging encoding errors
Glad to help. Out of curiosity, where are you deploying that your production server has only Python 2.3? There's been a conversation over on the developer's list about when to drop support for Python 2.3 in Django, and the general feeling seems to be that 2.3 ought to be getting pretty rarely seen nowadays. I'm wondering if you still see needing to run on Python 2.3 in 3 months time, 6 months time, etc.? Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
No module named MySQLdb
I installed Django and started my project on a server running Plesk. I've set up my vhost.conf as follows: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE twinsister.settings PythonOption django.root /mysite PythonDebug On PythonPath "['/var/www/vhosts/twinsistermusic.com/django'] + sys.path" Whenever I point my browser at twinsistermusic.com/mysite/ I get the following error: ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb Now, I'm pretty sure I installed MySQLdb correctly, as I was able to use syncdb with no problems and am able to import MySQLdb from within the Python interpreter. So, what gives? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Solution for use Django with Ejabberd ?
I want to use my django website with chat system ( ejabberd ). I don't know how to help 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-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 Model Inline with Group Model
Hey Karen, I have the setup as you have posted above, however i neither see GroupLevels model or the GroupLevels model inline with the Groups admin section. Indeed i am trying to get the GroupLevels model to display where the Groups section is in admin, however i have tried both scenarios and neither seem to work? Am i missing something? Thanks Karen On Dec 3, 6:49 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Dec 3, 2008 at 2:46 PM, VoiDeT <[EMAIL PROTECTED]> wrote: > > > Hi Karen, > > > Thanks alot for your quick reply! > > Indeed the admin.site.register(Group, GroupAdmin) was meant to write > > as admin.site.register(GroupLevels, GroupAdmin). However when i do > > this it doesn't display it inline, instead merely throws back an error > > saying Group doesn't have a foreignkey to GroupLevels. > > > So what i have above is trying to link GroupLevels inline with the > > Group model, or no? > > > What am i missing here? > > I think you've got things backwards in terms of what should be specified as > Inline and what should be registered. You're trying to inline Groups in > GroupLevels, but your models as specified support inlining GroupLevels in > Groups: > > class GroupLevelsInline(admin.TabularInline): > model = GroupLevels > > class GroupAdmin(admin.ModelAdmin): > inlines = [GroupLevelsInline,] > > admin.site.register(Group, GroupAdmin) > > Karen --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
Hey Karen, I have tried this scenario above, however the GroupLevels does not show inline with the Groups Model in Admin. I don't understand why not, no errors, just simply does not display. I have also tried to inline the Groups Model into the GroupLevels Model yet i get an error saying that Groups doesn't have a foreignkey to GroupLevels which is true. So what am i missing here? This is my code now: class GroupLevels(models.Model): group = models.ForeignKey(Group, unique=True) shows = models.PositiveIntegerField(default=0) items = models.PositiveIntegerField(default=0) class Meta: verbose_name_plural = "Group Permissions" verbose_name = "Group Permission" def __unicode__(self): return self.group.name class GroupLevelsInline(admin.TabularInline): model = GroupLevels class GroupLevelsAdmin(admin.ModelAdmin): inlines = [GroupLevelsInline,] admin.site.register(Group, GroupLevelsAdmin) --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
On Wed, Dec 3, 2008 at 7:08 PM, VoiDeT <[EMAIL PROTECTED]> wrote: > > Hey Karen, > > I have tried this scenario above, however the GroupLevels does not > show inline with the Groups Model in Admin. I don't understand why > not, no errors, just simply does not display. I have also tried to > inline the Groups Model into the GroupLevels Model yet i get an error > saying that Groups doesn't have a foreignkey to GroupLevels which is > true. > > So what am i missing here? > > This is my code now: > > class GroupLevels(models.Model): >group = models.ForeignKey(Group, unique=True) >shows = models.PositiveIntegerField(default=0) >items = models.PositiveIntegerField(default=0) > >class Meta: >verbose_name_plural = "Group Permissions" >verbose_name = "Group Permission" > >def __unicode__(self): >return self.group.name > > class GroupLevelsInline(admin.TabularInline): >model = GroupLevels > > class GroupLevelsAdmin(admin.ModelAdmin): >inlines = [GroupLevelsInline,] > > admin.site.register(Group, GroupLevelsAdmin) > Since you are overriding an existing admin definition, you'll need to admin.site.unregister(Group) before you can register your own. Not sure why you are not seeing an AlreadyRegistered exception -- are you including the admin defs in your models.py file? You should put them in an admin.py file and use admin.autodiscover() in your urls.py. If you do that with what you have now I think you will see AlreadyRegistered when you attempt to navigate to the admin url, which you can fix by first unregistering the existing Group admin before registering your own. Karen --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
Excellent! That worked fine, i guess i had to unregister it first and then dump my code into the admin.py file. However now the Group is a multiple select widget whereas before it would use a widget that i could add group permissions and take them away via an arrow to two neighbouring multiple select boxes. I'm looking at the models.py file in django.contrib.auth.models and wonder how i would go about bringing back this widget? Thanks for all your help Karen --~--~-~--~~~---~--~~ 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: HttpResponse.set_cookie defaults?
To answer my own question - the SESSION_COOKIE_* variables are not used in set_cookie. You'll have to pass in these things yourself! John On Dec 3, 3:02 pm, John Boxall <[EMAIL PROTECTED]> wrote: > From the documentation it's not obivous what the defaults are for the > set_cookie() > function.http://docs.djangoproject.com/en/dev/ref/request-response/?from=olddo... > > I've read about the various django SESSION_COOKIE_* > settings:http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#sessi... > > Does set_cookie use these settings as defaults? Or do I need to pass > them in? > > Thanks, > > 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 -~--~~~~--~~--~--~---
How construct specific complex queries?
I'm trying to construct complex queries, to better use the database (fewer hits, less slowdown). The models: List model, has a boolean called Public. Item model, is related to the List model via foreign key. Visibility model, is related to the Item model via foreign key, and has information like first name, last name, and email, and a visible boolean. I'm trying to be able to eliminate all the items with visibility constraints attached to them for anonymous users via this, but it doesn't look quite right: if user.is_anonymous(): #gets all the items with no visibility constraints. items = ListItem.objects.filter(WList__exact=wlist_id).exclude (visibility__isnull=True) If the user is not anonymous, I need to either do a match with the first name, last name, or the email, and then exclude all of those with Visibility.Visible=False for the match. (Implicitly, that leaves all the items with the Visible=True match for this specific user) I figure, then that I just need to use the query above ORed with the query for all the items without visibility constraints. Here's what I have... is it right? else: #first get all items with specific viewing for this specific user items = ListItem.objects.filter(WList__exact=wlist_id) items.filter(Q(visibility__FirstName__iexact=user.first_name) | Q(visibility__LastName__iexact=user.last_name) | Q (visibility__Email__iexact=user.email)) items.exclude(visibility__Visible__exact=False) items = items | ListItem.objects.filter (WList__exact=wlist_id).exclude(visibility__isnull=True) Thank you for your help, in advance. --~--~-~--~~~---~--~~ 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: No module named MySQLdb
On Dec 3, 5:54 pm, Udbhav <[EMAIL PROTECTED]> wrote: > > Whenever I point my browser at twinsistermusic.com/mysite/ I get the > following error: > > ImproperlyConfigured: Error loading MySQLdb module: No module named > MySQLdb > > Now, I'm pretty sure I installed MySQLdb correctly, as I was able to > use syncdb with no problems and am able to import MySQLdb from within > the Python interpreter. So, what gives? Perhaps apache (or whatever user apache runs under in your system) doesn't have permission to read/execute wherever you installed MySQLdb? I think I had this issue. I also ran into the "egg" issue for MySQLdb, which is documented in the FAQ. --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
On Wed, Dec 3, 2008 at 8:04 PM, VoiDeT <[EMAIL PROTECTED]> wrote: > > Excellent! > That worked fine, i guess i had to unregister it first and then dump > my code into the admin.py file. > However now the Group is a multiple select widget whereas before it > would use a widget that i could add group permissions and take them > away via an arrow to two neighbouring multiple select boxes. I'm > looking at the models.py file in django.contrib.auth.models and wonder > how i would go about bringing back this widget? > Look in django/contrib/auth/admin.py to see what the original Group admin definitions are. Karen --~--~-~--~~~---~--~~ 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: Webservers, Django thread-safeness, etc.
Actually, that statement, "to the best of anyone's knowledge, Django does not have issues running in threaded servers, and if/when bugs are found which contradict that we fix them" is what I was looking for. I probably should have asked, "Is Django intended and designed to be thread safe?" Obviously any large piece of software is susceptible to the introduction of bugs, and of course authors of extensions and application (e.g. programmers like me) can introduce non-threadsafe code. The important bottom line implied is that any thread unsafeness in the Django infrastructure would only be due to a bug, so such problems are most likely in my own development code. --~--~-~--~~~---~--~~ 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 Model Inline with Group Model
Perfect! Thanks alot Karen :) Just getting my bearings into the plentiful overriding :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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: open source project management app that uses django?
Margie, If you can think up a decent model, you might be able to setup the core of the project management application in the Django contrib.admin module. Development will go fast as long as you can stay with standard CRUD pages. The admin model will also give you the user security hooks necessary for the manager and employees. As soon as you nee a need for reporting pages or ways to do things a little more complex than the admin can give you, you can build custom pages for those. But I would think you could have 80% of your app running only by setting up the database models and nice admin pages. Maeck On Dec 3, 3:41 pm, Margie <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I would like to create a django project managment web app to be used > internally in my company. I am a software developer, but have little > experience with web apps other than my recent work going through the > sams django tutorial book. > > I'm wondering if anyone knows of any open source/free django web app > that I might be able to use to get started on this project. Let me > describe the usage model to give you an idea of what I'm aiming for. > > At a very high level, the usage model for this web app is that a > "manager" assigns tasks to "employees" on a weekly basis. Associated > with each task is a set of measurements that must be performed by the > employee as he/she does the task. The measurements vary based on the > task, and somemes the measurement is reported with a comment string, > sometimes a number, or sometimes a check mark in one of 'n' radio > boxes. As the employees complete the tasks, they fill in the > measurements. At the end of the week, the manager can look at each > task and review the resulting measurements, and based on that data, > decide the next weeks' tasks. > > Unlike a project mangament tool like MS Project, which helps you > schedule and gannt chart the schedule, this is really a tool to for > enhancing project communication. It is intended to allow the manager > to easily communicate tasks to the employees, get the results back, > and then make decisions about what the next set of tasks sould be. > All without having to spend a lot of time emailing and talking to > people. In the environement where it will be used, the manager is > getting results back from maybe 100 different employees, each of which > have a few tasks to do. The data is not complex, but there is just > too much of it to manage without a tool. Currently folks are using > wiki and excel, but in my opninion this is not really automated > enough. > > My thought is that a django web client could provide a very simple and > easy to use interface, and could also be extended to get all sorts of > nice long term trend information. For exmaple, t would be interesting > to know if a project being run at site A executes task 'foo' more > frequently or for longer periods of time than a project being run at > site B. As data is across multiple similar projects, it seems that it > could be mined for lots of interesting info to help improve the > productivity of future projects. > > Ok - so hopefully you get the idea. Now for my questions: > > * Does anyone know of existing web apps (django or otherwise) like > that already exists? > > * Does this sound like something that would be good to do in Django? > > * Does anyone know of any free/open source software (django based) > that I could use as a starting point? Not being a web developer, I > know that if I do this from scratch, I will probably not do a great > job. No doubt there are a ton of intracacies to window layout, the > structure of the models, the html templates, and other things I > haven't even thought of. So I'm thinking it would be great to > bootstrap from some existing code, even if it doesn't do quite what I > want. I would be happy to contribute my own work back to the open > source community. > > Thanks for any ideas! > > Margie --~--~-~--~~~---~--~~ 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: Question about i18n
On Wed, 2008-12-03 at 12:51 +0100, Elvis Stansvik wrote: > Hello django-users, first post to this list :) > > I often use the i18n support of Django in my projects, and I have a > small annoyance/problem that maybe someone can help me with. > > If I decide to customize e.g. admin/index.html, by copying it over > from django to my project, strings in that template such as "My > Actions" will now be treated as untranslated by manage.py makemessages > -a, even though they are indeed translated in Django's own django.po. > > This is all logical and all, and I can see why it is so, but it makes > my project's django.po unnecessarily cluttered with "untranslated" > strings that I in fact don't have translate, since they are translated > in Django's own django.po. There isn't a way to do this. Worth looking at whether there's a simple way to do this, although I can see it being slightly controversial: if some string is in Django's core, but not translated for language X, people are going to complain that they cannot translate it in there PO file because it's not included and they're being held hostage by the upstream Django translator. Adding yet another option is a possibility, although it's way down the list of preferred options, since adding options is always sub-optimal. Regards, Malcolm --~--~-~--~~~---~--~~ 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: Webservers, Django thread-safeness, etc.
On Wed, 2008-12-03 at 17:42 -0800, SteveB wrote: > Actually, that statement, "to the best of anyone's knowledge, > Django does not have issues running in threaded servers, and if/when > bugs are found which contradict that we fix them" is what I was > looking > for. > > I probably should have asked, "Is Django intended and designed > to be thread safe?" Yes. We've invested of the order of hundreds of hours of work into that aspect. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Does a Template Factory system exist, or do I need to build it?
Hello, I have a site that we plan to localize for different countries (all English speaking at this point.) Most of the templates in the site will localize fine as they are, but a few will need to be changed. I would like to have one set of templates that is the international (default) set, and then only create country specific templates when necessary. Django template inheritance is excellent, and where I hope to find a solution. What I need is a way for my view methods to forward to generic template names, like 'home.html', 'info.html', etc, which correspond to the default set of templates, but if any of those templates have been overridden with a country specific template, (and the user is using the site from that locale,) that country specific one, for example 'home_au.html', should be used. I'm guessing I need to build a simple factory, and have all my views call it, and then rest the whole design on good file naming patterns. Any thoughts? 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: Does a Template Factory system exist, or do I need to build it?
On Wed, 2008-12-03 at 19:19 -0800, ristretto.rb wrote: > Hello, > > I have a site that we plan to localize for different countries (all > English speaking at this point.) Most of the templates in the site > will localize fine as they are, but a few will need to be changed. I > would like to have one set of templates that is the international > (default) set, and then only create country specific templates when > necessary. > > Django template inheritance is excellent, and where I hope to find a > solution. What I need is a way for my view methods to forward to > generic template names, like 'home.html', 'info.html', etc, which > correspond to the default set of templates, but if any of those > templates have been overridden with a country specific template, (and > the user is using the site from that locale,) that country specific > one, for example 'home_au.html', should be used. This is one of the lesser-known features of Django and incredibly useful. You can provide a list of template names that are to be tried in order and the first one that is found is loaded. You can pass a list of templates to render_to_response(), since it uses django.template.loader.render_to_string(), which understands a list as the first argument. Alternatively, you can use the django.template.loader.select_loader() call directly to load the template. You'll have to call render() on the template and put it in an HttpResponse object yourself in that case, so normally render_to_response() is going to be more useful. Documentation available at http://docs.djangoproject.com/en/dev/ref/templates/api/#the-python-api In your particular case, you'll arrive at the point where you're ready to render the template and will know the language code. So pick a consistent naming scheme and you'll be able to do something like this (assuming 'locale' contains the locale you want to use) at the end of your view function: return render_to_response(['home_%s.html' % locale, 'home.html'], ) If the 'home_au.html' template doesn't exist (and, personally, I can't understand any site that doesn't make the Australian version the default!), it will load the 'home.html' version. Regards, Malcolm --~--~-~--~~~---~--~~ 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 construct specific complex queries?
Never mind, I've got it answered. For the record, this is what works: if user.is_anonymous(): #gets all the items with no visibility constraints. items = ListItem.objects.filter(WList__exact=wlist_id).exclude (visibility__isnull=False) else: #first get all items with specific viewing for this specific user items = ListItem.objects.filter(WList__exact=wlist_id) items = items.filter((Q (visibility__PersonFirstName__iexact=user.first_name) & Q (visibility__PersonLastName__iexact=user.last_name)) | Q (visibility__Email__iexact=user.email)) items = items.exclude(visibility__Visible__exact=False) items = items | ListItem.objects.filter (WList__exact=wlist_id).exclude(visibility__isnull=False) What this does is makes sure that all privacy constraints are properly adhered too. -Zeroth On Dec 3, 5:36 pm, Zeroth <[EMAIL PROTECTED]> wrote: > I'm trying to construct complex queries, to better use the database > (fewer hits, less slowdown). > > The models: > List model, has a boolean called Public. > Item model, is related to the List model via foreign key. > Visibility model, is related to the Item model via foreign key, and > has information like first name, last name, and email, and a visible > boolean. > > I'm trying to be able to eliminate all the items with visibility > constraints attached to them for anonymous users via this, but it > doesn't look quite right: > > if user.is_anonymous(): > #gets all the items with no visibility constraints. > items = ListItem.objects.filter(WList__exact=wlist_id).exclude > (visibility__isnull=True) > > If the user is not anonymous, I need to either do a match with the > first name, last name, or the email, and then exclude all of those > with Visibility.Visible=False for the match. (Implicitly, that leaves > all the items with the Visible=True match for this specific user) I > figure, then that I just need to use the query above ORed with the > query for all the items without visibility constraints. Here's what I > have... is it right? > > else: > #first get all items with specific viewing for this specific > user > items = ListItem.objects.filter(WList__exact=wlist_id) > items.filter(Q(visibility__FirstName__iexact=user.first_name) > | Q(visibility__LastName__iexact=user.last_name) | Q > (visibility__Email__iexact=user.email)) > items.exclude(visibility__Visible__exact=False) > items = items | ListItem.objects.filter > (WList__exact=wlist_id).exclude(visibility__isnull=True) > > Thank you for your help, in advance. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
App Name In Admin
Hi All, Around two weeks ago I inquired about customizing the "App Name" in the the Admin Interface. I came up with a solution which involves copying the original "django.contrib.admin, sites.py" over to project level and did what I needed to do to make it so I could have a custom app name and use that instead of using the default django admin site. Now, I can use this going forward in future projects. So far it hasn't caused any problems that I have noticed but the only thing for me to figure out is fixing the breadcrumbs when I am in the add form. The breadcrumbs are perfect when I am in a change list and higher. Here's what I have to do going forward in future projects. Like when I go and do a "manage.py startproject", after the the project files are created I than copy over my sites.py(myAdmin.py). Register my models with myAdmin and go on my merry way. When I register my model I do it like normal but I throw a extra argument on the end which is called "show_app_name='whatever I want'". Then that's where I had to go into the sites.py file and add and/or change a few lines. If anyone is interested specifically what I did to my "myAdmin.py" let me know and I will post or reply directly. I'm not totally sure what the rules are, if any as far as posting modifications to the original django code so I just want to be safe on that one. I would say that it's only 7 to 10 lines of code. Why copy the myAdmin.py instead of just importing it though python? Well that's sort of because of my own personal situation and I will get to that later. I have 2 computers at work and 2 at home. When I send projects and/or apps to work or home or vice versa I don't want to run into a instance where I one day i forget to send that too. I will admit that its not pretty but it works. I saw on some django blogs about people copying functions and classes from particular admin .py files and changing them at project level and doing that for several projs or apps which I think is a little over the line. But they did make me realize that there are some instances where you just have to do it, for now anyway. (totally unrelated to my issue). So i do realize this sort of violates the DRY principal but, I feel that it helps me understand the django framework a little better and I don't and won't have to touch the default sites.py. Now I am interest in what some others in the group have done for this issue(if they wanted or needed to). Not the code directly but sort of the procedures as I am open to other ideas. I don't think I want to use this as a permnent solution. Thanks, Steve P --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Can javascript call a python script?
Hello, this might be a silly question, but I'm wondering if javascript can call a python script, and if so, how? To elaborate, I'm trying to customize the admin change_list page so that editing can be done directly from the change_list, instead of clicking into the admin change_form page. To do this, I have a javascript that pops up a prompt box when an element in the change_list table is clicked. I'd then like to call a python script to modify that element in the database (since I don't believe the DB can be modified directly in the javascript). If this is unnecessary or just plain wrong, or if someone has a better way of editing items directly from the change_list, please let me know! Thanks much for the help. --~--~-~--~~~---~--~~ 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: Does a Template Factory system exist, or do I need to build it?
Bloody brilliant! thanks for the reply Malcolm. gene On Dec 4, 4:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-12-03 at 19:19 -0800, ristretto.rb wrote: > > Hello, > > > I have a site that we plan to localize for different countries (all > > English speaking at this point.) Most of the templates in the site > > will localize fine as they are, but a few will need to be changed. I > > would like to have one set of templates that is the international > > (default) set, and then only create country specific templates when > > necessary. > > > Django template inheritance is excellent, and where I hope to find a > > solution. What I need is a way for my view methods to forward to > > generic template names, like 'home.html', 'info.html', etc, which > > correspond to the default set of templates, but if any of those > > templates have been overridden with a country specific template, (and > > the user is using the site from that locale,) that country specific > > one, for example 'home_au.html', should be used. > > This is one of the lesser-known features of Django and incredibly > useful. You can provide a list of template names that are to be tried in > order and the first one that is found is loaded. You can pass a list of > templates to render_to_response(), since it uses > django.template.loader.render_to_string(), which understands a list as > the first argument. Alternatively, you can use the > django.template.loader.select_loader() call directly to load the > template. You'll have to call render() on the template and put it in an > HttpResponse object yourself in that case, so normally > render_to_response() is going to be more useful. Documentation available > athttp://docs.djangoproject.com/en/dev/ref/templates/api/#the-python-api > > In your particular case, you'll arrive at the point where you're ready > to render the template and will know the language code. So pick a > consistent naming scheme and you'll be able to do something like this > (assuming 'locale' contains the locale you want to use) at the end of > your view function: > > return render_to_response(['home_%s.html' % locale, > 'home.html'], > ) > > If the 'home_au.html' template doesn't exist (and, personally, I can't > understand any site that doesn't make the Australian version the > default!), it will load the 'home.html' version. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Any ideas why this code won't work in a post save signal, but will in the shell?
def post_save_user_handler(sender, **kwargs): user = kwargs['instance'] if user.is_staff: # only give add_staffprofile permissions to staff p_add_perm = Permission.objects.get (codename='add_staffprofile') p_change_perm = Permission.objects.get (codename='change_staffprofile') try: user.get_profile() # See if there is a profile already (raises exception if there isn't) except: # user doesn't have a profile, give them add_staffprofile permissions if p_add_perm not in user.user_permissions.all(): user.user_permissions.add(p_add_perm) else: # user has a profile already, remove add_staffprofile and add change_staffprofile if p_add_perm in user.user_permissions.all(): user.user_permissions.remove(p_add_perm) if p_change_perm not in user.user_permissions.all(): user.user_permissions.add(p_change_perm) signals.post_save.connect(post_save_user_handler, sender=User) # Hopefully User is setup by now... ### I have a new user who is a staff member but doesn't have a profile yet. Each time the user is edited (saved) I want to check if they are still staff and if they have a profile created. If they do, I want to remove their add_staffprofile permission and give them a change_staffprofile permission instead. If they don't have a profile, I want to make sure they have an add_staffprofile permissions. I can run this from the interactive prompt (python manage.py runserver) and it works as expected (user gets add_staffprofile permission). But when I save the user in the admin (as a staff member without a profile) the permission is never added. Thanks for any pointers... Andrew. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
need to override validation logic
I have a form that requires more complex validation logic than is provided through the default form.is_valid implementation. As an example, I have a form with properties A and B. One of A or B must be set. If neither is set, a validation error should be raised. Can someone show me an example of overriding is_valid()? Ideally, I would want the validation error associated not with an individual form field, but with the entire form. Also, this kind of "business logic" probably belongs in the model itself. Judging from previous threads, it looks like model validation is a work in progress. Is it ready in 1.0? What is the suggested approach for what I want to accomplish? Thanks, Nate --~--~-~--~~~---~--~~ 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: Can javascript call a python script?
Eric wrote: > Hello, this might be a silly question, but I'm wondering if javascript > can call a python script, and if so, how? > I believe Javascript can execute external commands, but I'm sure that it'd be turned off entirely for security reasons. I wouldn't trust client side code to modify my database any day. It sounds like you're asking if Javascript can run a python script on the server. Technically, any time a request is made to a webserver code (including python scripts) can be run on the server, and Javascript can make server requests. That's what Ajax is for. The javascript will send a request to the server without reloading the page in the browser, and can (optionally) change something in the loaded page based on data received by the response, while the server can do whatever it wants– including updating a database. Hopefully this is helpful! Jeff Anderson signature.asc Description: OpenPGP digital signature
issues with .96 tutorial
I've recently set up a virtual server w/ godaddy and followed http://www.howtoforge.com/how-to-install-django-on-fedora9-apache2-mod_python to install django. I'm following the tutorial and am up to setting up the admin section and configuring the urls.py for the polls model. this is what is happening when i uncomment the line it says to. http://kennethdavid.net/kdwCode/admin/ i'm using kdwCode instead of mysite, and have been through out the tutorial. I'm pretty much new to running my own server, and obviously to python and django. Everything has been, thus far, set up as per the tutorial. http://www.djangoproject.com/documentation/0.96/tutorial02/ thanks in advance for any help --~--~-~--~~~---~--~~ 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: need to override validation logic
On Wed, 2008-12-03 at 21:18 -0800, Nate wrote: > I have a form that requires more complex validation logic than is > provided through the default form.is_valid implementation. > > As an example, I have a form with properties A and B. One of A or B > must be set. If neither is set, a validation error should be raised. > Can someone show me an example of overriding is_valid()? Ideally, I > would want the validation error associated not with an individual form > field, but with the entire form. I spent an entire afternoon of my life writing up the documentation for that a couple of months ago. An entire afternoon that I'll never get back. So read the docs! See http://docs.djangoproject.com/en/dev/ref/forms/validation/ . > Also, this kind of "business logic" probably belongs in the model > itself. Judging from previous threads, it looks like model validation > is a work in progress. Correct. > Is it ready in 1.0? No. A "must have" for 1.1, however. > What is the suggested > approach for what I want to accomplish? See above and http://www.pointy-stick.com/blog/2008/10/15/django-tip-poor-mans-model-validation/ . Basically, you fake it using form validation even if it's just for the model at the moment. Regards, Malcolm --~--~-~--~~~---~--~~ 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: issues with .96 tutorial
On Wed, 2008-12-03 at 21:27 -0800, garagefan wrote: > I've recently set up a virtual server w/ godaddy and followed > http://www.howtoforge.com/how-to-install-django-on-fedora9-apache2-mod_python > to install django. > > I'm following the tutorial and am up to setting up the admin section > and configuring the urls.py for the polls model. this is what is > happening when i uncomment the line it says to. > http://kennethdavid.net/kdwCode/admin/ > The error message tells you exactly what the problem is: the URL you are using for the admin is not the pattern you are trying to match (your URL Conf pattern is expecting /admin/, not /kdwCode/admin/). So adjust the URL patter. > i'm using kdwCode instead of mysite, and have been through out the > tutorial. > > I'm pretty much new to running my own server, and obviously to python > and django. Everything has been, thus far, set up as per the tutorial. > > http://www.djangoproject.com/documentation/0.96/tutorial02/ Seriously, if you're just getting started, is there any reason you aren't using Django 1.0? There were only a few thousand bug fixes and code improvements since 0.96; you'll see lots of benefits. The only people using 0.96 should be those with existing sites using that code. Regards, Malcolm --~--~-~--~~~---~--~~ 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: need to override validation logic
On Thursday 04 Dec 2008 10:59:13 am Malcolm Tredinnick wrote: > > As an example, I have a form with properties A and B. One of A or B > > must be set. If neither is set, a validation error should be raised. > > Can someone show me an example of overriding is_valid()? Ideally, I > > would want the validation error associated not with an individual form > > field, but with the entire form. > > I spent an entire afternoon of my life writing up the documentation for > that a couple of months ago. An entire afternoon that I'll never get > back. So read the docs! See > http://docs.djangoproject.com/en/dev/ref/forms/validation/ . an afternoon very well spent! One read has cleared all my queries on this point. Excellent work. -- regards KG http://lawgon.livejournal.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: No module named urls
It's odd... I'm getting the exact same error at the exact same spot, running Django trunk r9550. What's strange is that it gets the 500 error on first request, and is ok all subsequent requests. On Nov 26, 9:34 am, TheIvIaxx <[EMAIL PROTECTED]> wrote: > So i've narrowed down the problem more. Its failing on the template > call to {% url django-admindocs-docroot as docsroot %} on the admin > page and all other pages. If i remove this line, the site works just > fine, recognizing all urls defined. Not sure just the template engine > would fail to see the urls.py, but everything else does. --~--~-~--~~~---~--~~ 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: No module named urls
On Wed, 2008-12-03 at 22:49 -0800, Rob Hudson wrote: > It's odd... I'm getting the exact same error at the exact same spot, > running Django trunk r9550. What's strange is that it gets the 500 > error on first request, and is ok all subsequent requests. That type of error means there's a problem importing something that the urls depends on. The first time around, the import attempt is raising an error. The next time around, the broken module is already "imported" (in the sense of bits of it being in sys.modules) and so a repeat attempt isn't made. Reversing URLs has to process all of your URLconf file, so the error isn't necessarily in the exact are you're reversing. It could be some view function somewhere in a nested URL Conf that is imported as part of working out all the reversable possibilities. This is an area where Django has poor error handling and we're slowly cutting them down. So you have to do a bit of commenting out and experimenting on the command line (just try a simple reverse() call each time to trigger it) to work out the problem. It's the first error that you should pay attention to here. Subsequent "successes" are misleading -- they're not raising errors, but something is still not working properly. Regards, Malcolm --~--~-~--~~~---~--~~ 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: modelformset_factory error: (Hidden field id) with this None already exists.
Hi, I haven't been able to solve this problem, but have made some progress: It's definitely *not* bug 9039. I've download the tests from that ticket and confirmed the fix was included in 1.0.2 final. The problem is related to using querysets with formset_factory. Ie, if I include a queryset filter, then I see this error. If I don't include a queryset, and thus edit all status reports, I don't see the error. Lastly, I've simplified my code producing the problem: my model: class StatusReport(models.Model): vehicle = models.IntegerField() report_date = models.DateField() status= models.CharField(max_length=10) and my view: def detail(request, vehicle_id): limited_reports = StatusReport.objects.filter(vehicle=vehicle_id) StatusFormSet = modelformset_factory(StatusReport, extra=0) if request.method == 'POST': formset = StatusFormSet(request.POST) if formset.is_valid(): formset.save() else: # with error #formset = StatusFormSet(queryset=limited_reports) # without error formset = StatusFormSet() return render_to_response('manage_articles.html', {'formset': formset, 'vehicle_id': vehicle_id}) Is this a bug in Django? If so, what should I include in the bug report? Thanks, -Josh On Dec 2, 3:49 pm, cyberjack <[EMAIL PROTECTED]> wrote: > Hi all, I've been stumped by this error for the past few days and > haven't made any progress. Could someone please help out? > > I've created a formset of seven entries, one for each day of the > previous week. The first submission works fine; all seven entries are > successfully submitted. Subsequent submissions, however, generate the > following error for each of the seven entries: > > (Hidden field id) Status report with this None already exists. > > I found an django issue from a few months ago which might be related > [1]. However, this bug was resolved back in Oct. and I'm running > 1.0.2, so I assume the CL is included. Is there any way to be > certain? > > Here are my models, simplified for space: > class Vehicle(models.Model): > number = models.IntegerField(unique=True) > > class StatusReport(models.Model): > date = models.DateField() > vehicle = models.ForeignKey(Vehicle, to_field='number') > status = models.CharField > ('status',max_length=8,choices=STATUS_REPORT_CHOICES) > > class Meta: > unique_together = ("date", "vehicle") > > And here's my view: > > def GenerateReportDate(request, vehicle_id, date): > # removed verification code for clarity > # week_start = monday before date. > # week_end = week_start + datetime.timedelta(7) > for i in range(7): > check_date = week_start + datetime.timedelta(i) > obj, created = StatusReport.objects.get_or_create(vehicle = int > (vehicle_id), > date = check_date, > defaults={'date': > check_date, > > 'vehicle':vehicle[0]}) > # Pull 7 reports for this week > reports = StatusReport.objects.filter( > vehicle__exact=vehicle_id > ).filter( > date__gte = week_start > ).filter( > date__lte = week_end > ).order_by("date") > > ReportFormSet = modelformset_factory(StatusReport, extra=0) > > if request.method == 'POST': > formset = ReportFormSet(request.POST, request.FILES) > if formset.is_valid(): > formset.save() > return HttpResponseRedirect('../done/') # Redirect after POST > else: > formset = ReportFormSet(queryset=reports) > return render_to_response('ops/report.html', {'formset': formset, > 'number': vehicle_id, > 'weekof': week_start}) > > Thanks for any help, > > -Josh > > [1]http://code.djangoproject.com/ticket/9039 --~--~-~--~~~---~--~~ 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: Can javascript call a python script?
On Dec 4, 4:09 am, Eric <[EMAIL PROTECTED]> wrote: > Hello, this might be a silly question, but I'm wondering if javascript > can call a python script, and if so, how? > > To elaborate, I'm trying to customize the admin change_list page so > that editing can be done directly from the change_list, instead of > clicking into the admin change_form page. To do this, I have a > javascript that pops up a prompt box when an element in the > change_list table is clicked. I'd then like to call a python script to > modify that element in the database (since I don't believe the DB can > be modified directly in the javascript). > > If this is unnecessary or just plain wrong, or if someone has a better > way of editing items directly from the change_list, please let me > know! Thanks much for the help. This is what AJAX is for. Get your Javascript to make a request to the server via XMLHTTPRequest, or whatever shortcuts your library of choice provides. The request should call a normal Django view which does whatever you need in the usual way, and provides a response back to the client-side Javascript either as XML, JSON or even ready- formatted HTML. So, using jQuery for example: $('.myelement').click(function() { $.post('/my-django-view/', {element: $(this).attr(id)}, function() { whatever actions you want the js to do on response ... } } ); -- 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 -~--~~~~--~~--~--~---
change/edit list not showing in admin interface
Hi, Going through chapter 6 in the djangobook. Using 1.1 SVN-9368. I think this chapter might be missing a step or two, or there's something I'm overlooking. In both the django development server and my apache server I can't seem to show the created models 'Publiser, Author and Books'. All models have class Admin: pass Everything else is visible and working, Auth and Site pages both, log in - log out, what have you. But no database models are showing. Could I be missing something in my urls.py or settings.py? currently in those files: # urls.py from django.conf.urls.defaults import * from django.contrib import admin from testproject.views import current_datetime, hours_ahead admin.autodiscover() urlpatterns = patterns('', (r'^time/$', current_datetime), (r'^time/plus/(\d{1,2})/$', hours_ahead), # Example: # (r'^testproject/', include('testproject.foo.urls')), (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/(.*)', admin.site.root), ) #settings.py ... ... TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) ROOT_URLCONF = 'testproject.urls' TEMPLATE_DIRS = ( 'C:/web/django/testproject/templates', ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admindocs', 'django.contrib.admin', 'testproject.books', ) 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: change/edit list not showing in admin interface
On Wed, 2008-12-03 at 23:53 -0800, Adam Yee wrote: > Hi, > > Going through chapter 6 in the djangobook. Using 1.1 SVN-9368. I > think this chapter might be missing a step or two, or there's > something I'm overlooking. What you're overlooking is that that book is written for Django 0.96 and some things have changed for Django 1.0. Read the 1.0-porting-guide.txt document that's in the release (and linked from the release notes on the wbesite) for details on everything that has changed. Also see this thread: http://groups.google.com/group/django-users/browse_thread/thread/3939ad7733f6a690 Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---