Re: Admin dashboard : hide and merge modules
Thanks, I don't though about users perms ! Grappelli just turn your admin more pretty, you should try: http://code.google.com/p/django-grappelli/ ! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin dashboard : hide and merge modules
On Tue, Aug 18, 2009 at 6:10 AM, JF Simonwrote: > > Hi men, > > I'm using Django + Grappelli and I'd like to know if there is a simple I don't know about grappelli, but I'd expect it to be at least as configurable as the standard django admin interface. > way to make some improvements to the dashboard (index) of the admin > such as : > > - hide modules (like Django_Evolution) You can create a user and assign them permissions only for certain apps/models. Just don't give them superuser permissions. The apps where users do not have any permissions will be hidden. > - merge modules (Auth entries with my User module) > - rename existing modules (not for now, just to know) I think these aren't possible currently. Matthias -- FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin dashboard : hide and merge modules
Hi men, I'm using Django + Grappelli and I'd like to know if there is a simple way to make some improvements to the dashboard (index) of the admin such as : - hide modules (like Django_Evolution) - merge modules (Auth entries with my User module) - rename existing modules (not for now, just to know) I dont found anything so I'm not sure anyone can help... Thanks for all (even if there is no way to do that !) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and CouchDB
You can google it. I have read once, but forget the link address now. 2009/8/18 sjtirtha> Hi, > > can some body share about his experience using Django and CouchDB? > I found some python API that can be used to access CouchDB, which one is > the best and suitable to Django Framework. > > Regards, > STeve > > > > -- Deng Chao --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin add / list / etc links broken?
On Mon, Aug 17, 2009 at 8:39 PM, ringemupwrote: > > I'm sure I'm doing something wrong, but I can't figure out what. The > list, add, and change links on the admin index all point to the > correct URLs, but all URLs under /admin are returning the admin index > page rather than the appropriate views. > > Using the following urls.py under Django 1.1: > > from django.conf.urls.defaults import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > > # Uncomment the next line to enable the admin: > (r'^admin/(.*)', include(admin.site.urls)), > ) > > Interestingly, using admin.site.root instead of include > (admin.site.urls) works, but my understanding is that the older use is > now deprecated, so I'd like to get this working. > > Any suggestions on what I've screwed up, or how to debug this? > Thast's because you are mixing strategies for specifying the admin entry on the URL map. Compare the relevant highlighted lines in the urlpatterns variable assignment in the following documentation code excerpts: http://docs.djangoproject.com/en/1.0/intro/tutorial02/#activate-the-admin-site (Django < 1.1) http://docs.djangoproject.com/en/dev/intro/tutorial02/#activate-the-admin-site (Django 1.1) -- Ramiro Morales http://rmorales.net PyCon 2009 Argentina - Vie 4 y Sab 5 Setiembre Buenos Aires, Argentina http://ar.pycon.org/2009/about/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: http://jacobian.org/tags/ - Source?
On Tue, Aug 18, 2009 at 11:41 AM, Victor Hooiwrote: > > heya, > > I was just wondering if anybody knew if the source to the tagging/ > bookmarking part of Jacob's site has been made available? > > http://jacobian.org/tags/ > > Or if there's any other django projects that provide something > similar? It seems fairly simple, but it's quite well done, and I was > just hoping to roll out something similar just for myself. django-tagging [1] is the most popular one. [1] http://code.google.com/p/django-tagging/ -- http://blog.scrum8.com http://twitter.com/scrum8 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
http://jacobian.org/tags/ - Source?
heya, I was just wondering if anybody knew if the source to the tagging/ bookmarking part of Jacob's site has been made available? http://jacobian.org/tags/ Or if there's any other django projects that provide something similar? It seems fairly simple, but it's quite well done, and I was just hoping to roll out something similar just for myself. Cheers, Victor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ways to implement a user - profile page
Thank you for your comments! > First, there is no need to have the username in the URL if this page > is visible only to the logged-in user. Instead, use the request.user > object inside your view (and, if necessary, the template). > The idea is that the profile page(what i have in my mind at least) is visible to all, but according to if you are logged in , it is your profile-home page. Or your friend's and you can leave comments, for example... > Second, to retrieve various info about the user there is no need for > custom tags. Instead, use the ORM to retrieve the related objects > directly. > nice idea, i will definitely try it! but then where do you use custom tags? i am hoping for more comments, nicolas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird: the path to the image, retrieved using filebrowser, is rewritten with a wrong relative instead of absolute.
sorry -- already a fix: http://code.google.com/p/django-tinymce/issues/detail?id=22=1=image=ID%20Type%20Status%20Priority%20Milestone%20Reporter%20Owner%20Summary On Aug 17, 7:31 pm, Cody Djangowrote: > I really don't know what is going on here. I've checked all my > settings for django-filebrowser and django-tinymce. > > 1) Using tinymce in admin, I'll click on "add image" > 2) Click on "filebrowser" icon in the image-prompt window, which opens > the filebrowser window > 3) Click on an image, which opens in a window > 4) Copy the absolute address from the url > 5) Paste it into the url field in the image-prompt window and click OK > 6) Image is now viewable in the textarea. > 7) click view object on site > 8) image has a broken link. I check the path for the image and it's > something like: instead > of the absolute path. > > * I've managed to have it display the absolute url if I include a www > in the absolute url field in the tinymce image-prompt window: > > ect: http://www.site.com/static/testimage.jpg (image url becomes > 'http://www.site.com/static/testimage.jpg') > instead ofhttp://site.com/static/testimage.jpg (image url becomes > '../../../../ > static/testimage.jpg') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django-tinymce and filebrowser, error.
Hi, Are you guys using the TinyMCE media files from a domain different from your admin site location? If so, you must point the media files (or at least the tiny_mce ones) to the same domain, because this addon tries to control the parent window from the popup window, and, if they're different, the popup ends blank, with strange titles. That's because the popup can't control the other window, limited by same- domain restriction. Regards, Diogo On Aug 17, 7:17 am, Parthianwrote: > Trevor, > > I've had problems with the same combination of tools. For me Popup > windows are completely blank. But after adding document.domain as > below I could get the popups to work but only in Firefox and Safari (I > think). > > Updated yourApp/yourMediaFiles/js/tinymce/tiny_mce_popup.js for > document.domain = 'yourdomain.com' to help with blank popup. Also same > in Templates/admin/base.html. There is a post somewhere on the web > that explains the exact details which I cannot find. A search should > find it. > > This may be irrelevant but worth a try and in any case try different > browsers to see if you get on better. > > Stuart > > On Aug 17, 6:23 am, tdelam wrote: > > > Hey, > > > I built a web site locally, I am using django-tinyce and the django- > > filebrowser, it works no problem on my local machine. As soon as I > > deploy it to the server I have a problem. The TinyMCE is showing up > > and working fine but when I click inside the image popup window to add > > an image, I get an error: > > > f is undefined > > [Break on this error] return f.apply(s || t, Array.prototype.slice.call > > (arguments, 1));\r\n - tiny_mce_src.js (line 9360) > > > This line of code looks like this: > > > return f.apply(s || t, Array.prototype.slice.call(arguments, 1)); > > > i am not really sure why and how to even debug this. I am a stumped > > because it works locally so I can't really tell where to go from here. > > Any suggestions? > > > Trevor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
the problem is that logging to a file is not going to work in a multiprocess environment. I'm using the logging library configured to log to syslog with fcgi and it is working out quite well. On Mon, Aug 17, 2009 at 11:10 AM, Mike Ramirezwrote: > On Monday 17 August 2009 10:24:18 am Lokesh Maremalla wrote: > > Hi, > > > > Included django-logging as described in the link. > > > > From the django-logging I can view the log messages on the screen at run > > time. But, I am not sure on saving the log messages from django-logging. > > Can I capture the log messages into my log file on a daily basis instead > of > > redirecting to screen. > > > > Regards, > > Lokesh > > > you would set up the file access similar to using the python logging module > [1] > > import logging > logging.FileHandler('myfile') > > > > Mike > > [1] > > http://www.mechanicalcat.net/richard/log/Python/Simple_usage_of_Python_s_logging_module > > This is also linked on django-logging's overview page. > > -- > "Hard work now leads to less work full stop" > >- Alan Cox > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin site : Redefining __init__ method for Form
Hello django users, I'm trying to override the __init__ method in forms.py for an application that extend the admin site. I'm doing this to initialize a ModelChoiceField of the form with user logged in, informations, so I'm trying to retrieve the user in my __init__ method... but I think I'm missing something :) So my code is the following (python 2.6.2/django 1.1): class InscriptionForm(forms.ModelForm): equipe = forms.ModelChoiceField(queryset=Equipe.objects.all(), required=False ) def __init__(self, *args, **kwargs): super(InscriptionForm, self).__init__(*args, **kwargs) try: user = kwargs.get('user') if user.get_profile().evenement: self.fields['equipe'] = forms.ModelChoiceField (queryset=Equipe.objects.filter(evenement=user.get_profile ().evenement), required=False ) else: self.fields['equipe'] = forms.ModelChoiceField (queryset=Equipe.objects.all(), required=False ) except: self.fields['equipe'] = forms.ModelChoiceField (queryset=Equipe.objects.all(), required=False ) My issue is that I never put explicitly the user in the call of the __init__. I supposed that is the admin internal mechanism that do the stuff, but I can't figure out where... so my kwargs.get('user') return nothing, that is pretty obvious. So my question is : how to retrieve the user logged in an AdminForm element??? Thx guys. Julien. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ways to implement a user - profile page
Just a couple brief thoughts. First, there is no need to have the username in the URL if this page is visible only to the logged-in user. Instead, use the request.user object inside your view (and, if necessary, the template). Second, to retrieve various info about the user there is no need for custom tags. Instead, use the ORM to retrieve the related objects directly. For example, imagine you have the model Comment which has the User as its ForeignKey; you can then use request.user.comment_set to retrieve all the comments made by that user. Or, as I prefer, use related_name in the Comment model definition, so you can do e.g. request.user.comments. For friends you would probably need a ManyToManyKey field, but the rest of the logic is the same. Berislav --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Formwizard and subforms
That's a given. But thanks for your input, very helpful! On Aug 18, 6:53 am, Wayne Koortswrote: > > Nobody can help me with this? > > If somebody: > > a) Has the answer and, > b) Has the time and, > c) The inclination to provide the answer, then they will do so. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin add / list / etc links broken?
I'm sure I'm doing something wrong, but I can't figure out what. The list, add, and change links on the admin index all point to the correct URLs, but all URLs under /admin are returning the admin index page rather than the appropriate views. Using the following urls.py under Django 1.1: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Uncomment the next line to enable the admin: (r'^admin/(.*)', include(admin.site.urls)), ) Interestingly, using admin.site.root instead of include (admin.site.urls) works, but my understanding is that the older use is now deprecated, so I'd like to get this working. Any suggestions on what I've screwed up, or how to debug this? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Weird: the path to the image, retrieved using filebrowser, is rewritten with a wrong relative instead of absolute.
I really don't know what is going on here. I've checked all my settings for django-filebrowser and django-tinymce. 1) Using tinymce in admin, I'll click on "add image" 2) Click on "filebrowser" icon in the image-prompt window, which opens the filebrowser window 3) Click on an image, which opens in a window 4) Copy the absolute address from the url 5) Paste it into the url field in the image-prompt window and click OK 6) Image is now viewable in the textarea. 7) click view object on site 8) image has a broken link. I check the path for the image and it's something like: instead of the absolute path. * I've managed to have it display the absolute url if I include a www in the absolute url field in the tinymce image-prompt window: ect: http://www.site.com/static/testimage.jpg (image url becomes 'http://www.site.com/static/testimage.jpg') instead of http://site.com/static/testimage.jpg (image url becomes '../../../../ static/testimage.jpg') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom table instead of "user" in django
On Mon, Aug 17, 2009 at 10:40 PM, Jonas Obristwrote: > > Here's what I did: > > I took the built in auth system and changed it a bit, or to be more > precise I changed all imports within auth (because I moved it within the > pythonpath) and edited models.py: > > http://dpaste.com/81651/ > > Whole code: > > http://www.ojii.ch/auth.tar.gz > > If you wanna use it: > > Add the folder in the archive to your pythonpath. > > Add 'auth' to your installed applications > > Set 'USER_MODEL' in your settings file to the model you use (string). Is it better to re-write the user model or to extend it? Any insights? Thanks in advance -- http://blog.scrum8.com http://twitter.com/scrum8 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom table instead of "user" in django
Thanks Jonas. Quick question - The difference in the models.py is I guess addition of these two imports - from django.db.models import get_model from django.conf import settings A dumb question, when you say "moved it within the pythonpath", what exactly does it mean ? On Aug 17, 8:40 am, Jonas Obristwrote: > Here's what I did: > > I took the built in auth system and changed it a bit, or to be more > precise I changed all imports within auth (because I moved it within the > pythonpath) and edited models.py: > > http://dpaste.com/81651/ > > Whole code: > > http://www.ojii.ch/auth.tar.gz > > If you wanna use it: > > Add the folder in the archive to your pythonpath. > > Add 'auth' to your installed applications > > Set 'USER_MODEL' in your settings file to the model you use (string). > > Done. > > NOTE: I did NOT test this yet! > > Jonas > > PlanetUnknown wrote: > > Guys, > > I have a quick question. I am attracted to django due to its > > flexibility however there is something bothering me now. > > My question is can I use a custom table, say "consumer" instead of the > > one provided my django ? > > Here are the reasons - > > 1.) I have my whole DB model around this consumer table and want to > > keep it. > > 2.) This table has a lot more fields than what the user has, which are > > custom and uses the "email address" as the username. > > > I know no. 2 has a solution of using a custom backend, but there are > > so many out there that they confuse me. Also,I don't want to use the > > "admin" part of django since I'll have a custom app. for that, but > > which works on "consumer" > > > I'm worried if I there is no way around using the django provided > > "user" I'll have to re-invent the wheel, is that true ? e.g. session > > management, etc. Not afraid of coding, but the whole reason I chose > > django was to not do this. > > > Any direction by the Gurus is appreciated. > > Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ways to implement a user - profile page
hi, i am new to django-universe. My goal is to make to make my first django application! I am trying to get a grip on the authentication system. I 've implemented login and logout operations. After a successful login i want the user transferred to his profile page. The profile page url looks like this: profiles/username. In this page will see: - a personal welcome message with his name - his avatar, his friends avatars - latest comments from friends and stuff like this. I was wondering which is the suggested way to implement this page. one way would be to have custom tags like: get_latest_entries get_friends another way would be to have a custom view function pass all this info... Is there any other way? which one would be the preferred? thanks in advance for your time and comments! nicolas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Formwizard and subforms
> Nobody can help me with this? If somebody: a) Has the answer and, b) Has the time and, c) The inclination to provide the answer, then they will do so. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Formwizard and subforms
Nobody can help me with this? On Aug 15, 10:14 am, Geewrote: > Hi, > > I am trying to build aformwizardthat includes a manytomany > relationship on one of the steps and I am stuck on to implement the > manytomany. The models are, (only for step in question) > > class Person(models.Model): > name = models.CharField > addr = models.ManyToMany(Phone) > > class Phone(models.Model): > PHONE_CHOICES(('H','Home'),('W",'Work'),('M','Mobile')) > phone= models.CharField(max_length=10) > phoneType = models.CharField(max_length=1, choices=PHONE_CHOICES) > > The models are setup this way on the premise that more than one person > could have any number of the same phone numbers. > > What I need to do is have a select box on the form that shows the > phone choices and when one is selected an option to add a new line to > the form that to retain that phone information for that type. > > Any help would be greatly appreciated. > > Thanks > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model instance refreshing
On Mon, Aug 17, 2009 at 1:31 PM, mettwochwrote: > > Hi, > > I use a session to store several instances of different models coming > from a: > > some_model.objects.get(pk = some_pk) > > When the data in the db changes the model instances in the session > still contain the old data. What would be a good strategy to make > shure that all objects in a session get fresh data on every request? > > Marc > > PS: Hopefully going live in 2 weeks ... to be continued > > > I would only store the PK in the session and use it to get a new instance of the model with every request. Colin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model instance refreshing
Hi, I use a session to store several instances of different models coming from a: some_model.objects.get(pk = some_pk) When the data in the db changes the model instances in the session still contain the old data. What would be a good strategy to make shure that all objects in a session get fresh data on every request? Marc PS: Hopefully going live in 2 weeks ... to be continued --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FileField problems - url attribute doesn't work, how do I do uploads?
On Monday 17 August 2009 01:10:33 pm Fluoborate wrote: > Hello All, > > I am being very perplexed and annoyed by models.FileField database > fields. I have two problems: > > 1. The filefield.url attribute gives the path on my hard disk, not the > internet URL that the file is being served to. The filefield.path and > filefield.name attributes also give the exact same result as .url. > > 2. How am I supposed to make a form where the user uploads something? > I think I can hack something together by reverse-engineering the Admin > page, and by looking around on the internet, but I don't see one good > and simple example. I want simple. > > My setup: > > Mac OS X 10.5.8 > Django 1.0.2 > Development server only, at the moment. > > #In settings.py: > MEDIA_URL = '/media/' > MEDIA_ROOT = '/Users/me/publications/' > > #In models.py: > class Publication(models.Model): > pdf = models.FileField(upload_to='pdf') > > #In urls.py: > urlpatterns += patterns('', >(r'^media/(?P.*)$', 'django.views.static.serve', > {'document_root': '/Users/me/publications'}), > ) > > I think that's all the relevant stuff. Some findings/example tasks: > > I upload a file, essay.pdf, using the Django Admin console. > http://127.0.0.1:8000/media/pdf/essay.pdf > #It works, there it is. > > In the shell, (python manage.py shell): > >>>essay.pdf.path > > u'/Users/me/publications/pdf/essay.pdf' > > >>>essay.pdf.name > > u'/Users/me/publications/pdf/essay.pdf' > > >>>essay.pdf.url > > u'/Users/me/publications/pdf/essay.pdf' > > Now that doesn't seem quite right. I have seen working examples, I > even made one once, I don't know what is wrong here. > If you're using the admin as the only way to upload files, I do this in one of my apps: By customizing the save_model[1] to handle the upload of files, write the files to the savel location, then return the relative path for the files under my MEDIA_ROOT, and save it to the imagefile field. class ImageAdmin(admin.ModelAdmin): list_display = ['name', 'gallery', 'date' ] search_fields = ['name', 'gallery__name'] prepopulated_fields = {'slug': ("name",), } list_filter = ['gallery', ] def save_model(self, request, obj, form, change): def uploadHandler(f, saveLocation): savePath = os.path.join(settings.MEDIA_ROOT, saveLocation, f.name) destination = open(savePath, 'w') for chunk in f.chunks(): destination.write(chunk) destination.close() return os.path.join(saveLocation, f.name) if request.FILES.has_key('imagefile'): obj.imagefile = uploadHandler(request.FILES['imagefile'], settings.GALLERY_SAVE_LOCATION) obj.save() admin.site.register(ImageFile, ImageAdmin) The FileFields upload_to[1] option can also take a callable to handle the file fields location, this uploadHandler can be placed there for a more robust application. The keys are write the file by reading the chunks[3] to the place you really want it stored and then return the relative path that's under the MEDIA_ROOT, then use the MEDIA_URL context processor[5] in your templates like myfile.name Mike [1] http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-methods [2] http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield [3] http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files [4] http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media -- Making one brilliant decision and a whole bunch of mediocre ones isn't as good as making a whole bunch of generally smart decisions throughout the whole process. -- John Carmack signature.asc Description: This is a digitally signed message part.
Re: Securing files held by FileField.
Thanks a lot, Javier! There were a few caveats to getting this to work for me, but I've gotten there, finally! For anyone else who wants to use this solution, check out this posting by a bloke named Andre, who was extremely helpful when I emailed him asking for a bit of a hand: http://andre.liquidmm.com/blog/2009/mar/24/secure-downloads/ Also, here is the homepage for the module: http://tn123.ath.cx/mod_xsendfile/ And here is a .deb for all you Debian based people: http://www.screenage.de/blog/2008/02/22/libapache2-mod-xsendfile-processes-x-sendfile-headers-with-apache2/ One extra note: if you are going above your DocumentRoot, you must use XSendFileAllowAbove On - for some reason I thought this was optional, and it caused me a couple of hours of 404s. Of course, Andre was helpful in helping realise my silliness. So, thanks to you all. This finishes my project for me =D Brenton. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FileField problems - url attribute doesn't work, how do I do uploads?
Hello All, I am being very perplexed and annoyed by models.FileField database fields. I have two problems: 1. The filefield.url attribute gives the path on my hard disk, not the internet URL that the file is being served to. The filefield.path and filefield.name attributes also give the exact same result as .url. 2. How am I supposed to make a form where the user uploads something? I think I can hack something together by reverse-engineering the Admin page, and by looking around on the internet, but I don't see one good and simple example. I want simple. My setup: Mac OS X 10.5.8 Django 1.0.2 Development server only, at the moment. #In settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = '/Users/me/publications/' #In models.py: class Publication(models.Model): pdf = models.FileField(upload_to='pdf') #In urls.py: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': '/Users/me/publications'}), ) I think that's all the relevant stuff. Some findings/example tasks: I upload a file, essay.pdf, using the Django Admin console. http://127.0.0.1:8000/media/pdf/essay.pdf #It works, there it is. In the shell, (python manage.py shell): >>>essay.pdf.path u'/Users/me/publications/pdf/essay.pdf' >>>essay.pdf.name u'/Users/me/publications/pdf/essay.pdf' >>>essay.pdf.url u'/Users/me/publications/pdf/essay.pdf' Now that doesn't seem quite right. I have seen working examples, I even made one once, I don't know what is wrong here. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to add coustom form to admin interface.
Hi. I hope someone can help me out. For my project i use entirely djagno admin interface. I Chose it because everything gets done by itself. So now i need to add a form more precisely for example one check-box, that it will be read when i execute save(). I don't want to add boolean field to my model, because in don't need it in my sql table. Thanks anyone to giving me right direction. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Exception in transaction block hidden by "InternalError: transaction aborted ..." exception
Hi My app saves data in a method with "@transaction.commit_manually". My code had a bug - a field in a model was the wrong datatype for what was passed in, so I got a DataError exception back. However, the only exception that was displayed to me was "psycopg2.InternalError: current transaction is aborted, commands ignored until end of transaction block". I had to comment out "@transaction.commit_manually" in order to get the real DataError exception to show. My code looks like this: @transaction.commit_manually def save(self): try: # save data here except BaseException as e: traceback.print_exc() # prints psycopg2.InternalError traceback transaction.rollback() else: transaction.commit() I'm sure there's a way to get the original, DataError, exception... can anyone help? Thanks, Darren --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django and CouchDB
Hi, can some body share about his experience using Django and CouchDB? I found some python API that can be used to access CouchDB, which one is the best and suitable to Django Framework. Regards, STeve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
PIL & imagefield validation
Hello On sunday i had problems with python when i installed stackless python. Now i have compiled and installed : setuptools & python-mysqldb and i got my django project up and running again. (i also reinstalled django-1.1), Then i compiled and installed, jpeg, freetyp2 and PIL. I also started using mod_wsgi instead of mod_python. But when uploading imagefield in form i get validationerror: Upload a valid image. The file you uploaded was either not an image or a corrupted image. Searchmonkey shows that it comes from field.py imagefield validation. before raising this error it imports Image from PIL, opens file and verfies it. I tried importing PIL from python prompt manually - it worked just fine. Same with Image.open and Image.verify. So what could by causing this problem? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
On Monday 17 August 2009 10:24:18 am Lokesh Maremalla wrote: > Hi, > > Included django-logging as described in the link. > > From the django-logging I can view the log messages on the screen at run > time. But, I am not sure on saving the log messages from django-logging. > Can I capture the log messages into my log file on a daily basis instead of > redirecting to screen. > > Regards, > Lokesh > you would set up the file access similar to using the python logging module [1] import logging logging.FileHandler('myfile') Mike [1] http://www.mechanicalcat.net/richard/log/Python/Simple_usage_of_Python_s_logging_module This is also linked on django-logging's overview page. -- "Hard work now leads to less work full stop" - Alan Cox signature.asc Description: This is a digitally signed message part.
Re: Logging mechanism in Django
Hi, Included django-logging as described in the link. >From the django-logging I can view the log messages on the screen at run time. But, I am not sure on saving the log messages from django-logging. Can I capture the log messages into my log file on a daily basis instead of redirecting to screen. Regards, Lokesh On Mon, Aug 17, 2009 at 9:16 PM, Mike Ramirezwrote: > On Monday 17 August 2009 07:56:48 am Lokesh wrote: > > Hi, > > > > I am trying to implement the logging (Code flow tracking) for my > > Django application. > > I would like to store the log messages on daily basis for my > > applications. > > > > Need help or suggestions on how we can implement the logging mechanism > > for an application. > > > > Regards, > > Lokesh > > > You can look at django-logging [1], it intergrates the python logging > module > with django as middleware. > > [1] http://code.google.com/p/django-logging/wiki/Overview > > Mike > > -- > I feel like I am sharing a ``CORN-DOG'' with NIKITA KHRUSCHEV ... > -- Thanks & Regards, Lokesh. lokeshmarema...@gmail.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using fixtures in tests
On Mon, Aug 17, 2009 at 11:10 AM, Marek Wawrzyczekwrote: > > Hi, > > > I've got an application called myapp > > In the main folder of django project there is initial_data.json file > containing initial data for the application > I also have file "simplefix.json" situated in myapp/fixtures > containing initial data for tests > > Then after calling: python manage.py test myapp: > > the following output is shown: > > (...creating tables and indexes) > > Installing json fixture 'initial_data' from absolute path. > Installed 114 object(s) from 1 fixture(s) > hello > > myapp/tests.py has the following content: > > > from django.test import TestCase > > class SimpleTestCase(TestCase): > >fixtures = ['simplefix.json'] > >def testOne(self): >print 'hello' > > > How can I load database during tests from defined fixture? I tried > putting simplefix.json in myapp/ in main project folder, in fixtures > directory in main project folder and none of that worked > What you have shown (with simplefix.json in your app's fixtures directory) should be working. How are you determining that it isn't? Note there is no feedback printed for non-initial-data fixtures loaded during testing, so you won't see a message for simplefix.json as you do for the initial data fixture. If you are determining that it isn't working because your test code can't access data that should have been loaded, then I'd suspect a typo in the file name somewhere. Unfortunately there is also no feedback for this case, so double check that you've got the file with the right name, and specified the right name in the TestCase fixtures attribute. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using fixtures in tests
On Mon, 2009-08-17 at 11:10 -0400, Marek Wawrzyczek wrote: > Hi, > > > I've got an application called myapp > > In the main folder of django project there is initial_data.json file > containing initial data for the application > I also have file "simplefix.json" situated in myapp/fixtures > containing initial data for tests ... > myapp/tests.py has the following content: > > > from django.test import TestCase > > class SimpleTestCase(TestCase): > > fixtures = ['simplefix.json'] > > def testOne(self): > print 'hello' > > > How can I load database during tests from defined fixture? I tried > putting simplefix.json in myapp/ in main project folder, in fixtures > directory in main project folder and none of that worked > You need to put in in $your_app_dir/fixtures/simplefix.json. Cheers, Cliff --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin site statics (CSS) seen via 'runserver' not via fcgi
Hi All, I'm trying to figure how to get the CSS to work on the /admin part of my django project. Based on the same settings.py the /admin show correctly when run with: python ./manage.py runserver 192.168.1.72:8000 When I run it via fcgi like this: python ./manage.py runfcgi host=192.168.1.72 port=8000 daemonize=false It's a no-show. The last one runs behind a poperly working lighttpd/fgci setup. I checked and indeed get a 404 on the .css files. I have been through the docs several times in regards to ADMIN_MEDIA_PREFIX and MEDIA_URL but I still seem to have a blind spot. Since I am satisfied with the admin interface (and layout). I want to avoid copying files from the "django/.../media" dir to my own static files project dir. Furthermore, the static files used in my own templates (like css, javascript, images) work in both situations. Would somebody be so kind to shine some light on my blind spot :) Thanx a lot Kind regards, Gerard. -- self.url = www.gerardjp.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
On Monday 17 August 2009 07:56:48 am Lokesh wrote: > Hi, > > I am trying to implement the logging (Code flow tracking) for my > Django application. > I would like to store the log messages on daily basis for my > applications. > > Need help or suggestions on how we can implement the logging mechanism > for an application. > > Regards, > Lokesh You can look at django-logging [1], it intergrates the python logging module with django as middleware. [1] http://code.google.com/p/django-logging/wiki/Overview Mike -- I feel like I am sharing a ``CORN-DOG'' with NIKITA KHRUSCHEV ... signature.asc Description: This is a digitally signed message part.
Re: Possible to use Django & MySQL with Python 2.6?
On Mon, Aug 17, 2009 at 10:20 AM, Streamweaverwrote: > It works fine for me with Python 2.6 on Linux (with the errors > mentioned above) . Windows is a bit of a problem as the mysql-python > library doesn't yet support 2.6. Since this has come up several times in different threads recently... No, those are not "errors". Errors would cause your application to crash and dump a traceback on the screen. What you are seeing are *warnings*, usually indicating that a bit of code is doing something that's deprecated. In other words, Python is saying "hey, this will work for now, but in future versions of Python it won't". The key there being "this will work for now". Staying clear on this distinction is of rather crucial importance, since at this point there are quite a few things that will raise deprecation *warnings* under Python 2.6, but which are not actually errors and do not actually crash your application -- they're merely telling you that down the road in a future Python version it'll stop working. -- "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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
On Mon, Aug 17, 2009 at 2:17 PM, Lokeshwrote: > I am trying to implement logging mechanism using Python library. But, > I am not sure on which mechanism/methodology used for Django > applications. > > Is there any predefined process or methodology to be followed for > Django applications for logging mechanism. > Not that I know of. Logging isn't really the realm of Django. Though conversely it won't meddle with your logging functionality. You are free to do what ever you would like to with your logging. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Possible to use Django & MySQL with Python 2.6?
It works fine for me with Python 2.6 on Linux (with the errors mentioned above) . Windows is a bit of a problem as the mysql-python library doesn't yet support 2.6. On Aug 17, 12:32 am, Continuationwrote: > According to the site of the python MySQL driver it only supports > Python 2.3 - 2.5:http://sourceforge.net/projects/mysql-python/ > > So is it possible to use Django & MySQL with Python 2.6? Is there any > workaround I can do to make it work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
Hi, I am trying to implement logging mechanism using Python library. But, I am not sure on which mechanism/methodology used for Django applications. Is there any predefined process or methodology to be followed for Django applications for logging mechanism. Regards, Lokesh On Aug 17, 8:05 pm, Joshua Russowrote: > On Mon, Aug 17, 2009 at 1:56 PM, Lokesh wrote: > > > I am trying to implement the logging (Code flow tracking) for my > > Django application. > > I would like to store the log messages on daily basis for my > > applications. > > > Need help or suggestions on how we can implement the logging mechanism > > for an application. > > Are you using the Python logging library or are you trying to create your > own?http://docs.python.org/library/logging.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using fixtures in tests
Hi, I've got an application called myapp In the main folder of django project there is initial_data.json file containing initial data for the application I also have file "simplefix.json" situated in myapp/fixtures containing initial data for tests Then after calling: python manage.py test myapp: the following output is shown: (...creating tables and indexes) Installing json fixture 'initial_data' from absolute path. Installed 114 object(s) from 1 fixture(s) hello myapp/tests.py has the following content: from django.test import TestCase class SimpleTestCase(TestCase): fixtures = ['simplefix.json'] def testOne(self): print 'hello' How can I load database during tests from defined fixture? I tried putting simplefix.json in myapp/ in main project folder, in fixtures directory in main project folder and none of that worked Regards, Marek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging mechanism in Django
On Mon, Aug 17, 2009 at 1:56 PM, Lokeshwrote: > > I am trying to implement the logging (Code flow tracking) for my > Django application. > I would like to store the log messages on daily basis for my > applications. > > Need help or suggestions on how we can implement the logging mechanism > for an application. Are you using the Python logging library or are you trying to create your own? http://docs.python.org/library/logging.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Success at using "reusable apps"?
That's a good idea. So you are suggesting, for example, that when the threadedcomment gets saved, that my app catch the post save signal and take its action then? I like that idea, I'm going to play around with that today. I hadn't thought about using signals before, but I guess that is the obvious solution to finding a way to do things in my own code without messing with the "reusable" app. Thanks for that suggestion! Margie On Aug 16, 10:41 pm, Andy McKaywrote: > On 16-Aug-09, at 8:50 PM, Margie Roginski wrote: > > > * modify the threadedcomments views.py code to take a callback > > function as an argument - that callback function could do my Task > > specific stuff as described above, but this would keep it more > > encapsulated within my Task app (but of course I would still have to > > modify threadecomments to take the callback arg) > > Or sounds like you could write a signal in your own code. > -- > Andy McKay > Clearwind Consulting:www.clearwind.ca > Blog:www.agmweb.ca/blog/andy > Twitter: twitter.com/clearwind --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Logging mechanism in Django
Hi, I am trying to implement the logging (Code flow tracking) for my Django application. I would like to store the log messages on daily basis for my applications. Need help or suggestions on how we can implement the logging mechanism for an application. Regards, Lokesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django template language issue
Thanks! On Aug 17, 11:53 am, David Zhouwrote: > On Mon, Aug 17, 2009 at 6:39 AM, Adonis wrote: > > My problem is that even if the 'projects' queryset is empty, it still > > includes the projects.html > > Is there another way to do it? > > If you're using at least Django 1.1, you can use the empty tag: > > http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-empty > > For example: > > {% for item in projects %} > > {% include projects.html %} > > {% empty %} > > There are no items in the project. > > {% endfor %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Eric Evans Value Objects
Hi Tibor, On Mon, Aug 17, 2009 at 4:17 AM, gentlestonewrote: > > I'm looking for a support for something like Eric Evans Value Objects > (http://domaindrivendesign.org/). For example, if I have a Person > model like > > class Adress(models.Model): > street = ... > city = ... > postal_code = ... > > class Person(models.Model): > home_adress = models.OneToOneField(Adress) > business_adress = models.OneToOneField(Adress) > > Adress is like a Value Object, but I don't want any adress table, nor > extra foreign key and database joins. My application is not made for a > National Post Office domain. I just want an Adress class whitout > database identity. I think you're approaching the problem incorrectly. When dealing with a relational database, go ahead and view things from a relational perspective. In this case, if you want your Person model to have zero, one, or multiple Addresses, and a single Address can be used by multiple people, what you want in Django is a ManyToMany field. Yes, this creates a couple more tables and the requisite joins, but as it so happens, that likely won't be a problem for you, as you are writing an application that is as you say "not made for National Post Office domain." In short, don't fight the relational model in this case. It is designed to handle such tasks. The only reason you might want to avoid an extra table or two is due to poor performance, but I suspect that you are optimizing prematurely. Until you have a large number of users, you don't need to worry about one M2M field. And your first choices for optimization in Django should be caching and setting up a separate image server, not database denormalization. Django's ORM is a very powerful tool, and it makes the developer's life a lot easier in many ways, but that in part is because the Django developers made design choices that reflect best practices and channel users in the proper direction. The fact that Django does not make it easy to do what you think you want is likely a sign that you are going upstream against the natural flow of Django. In short, take it as a warning sign that you should rethink your approach. Try working with Address as a ManyToMany field, and see whether that works for your application. From there, if it presents a problem, you can always rethink later, and you will have the benefit of knowing what problems you need to work around. Hope that helps, ---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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Override __init__()
On Aug 14, 4:26 pm, Daniel Rosemanwrote: > On Aug 14, 3:50 pm, Léon Dignòn wrote: > > > Hi Emily, > > > thanks so far! > > > unfortunately this line: > > > > instance = getattr(kwargs, 'instance') > > throws this error: > > > Exception Value: 'dict' object has no attribute 'instance' > > > what next? > > That should be: > > instance = kwargs.get('instance') > -- > DR. Yeah sorry - was writing it in a hurry before going somewhere. Oops! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: digg style pagination
Hi, Thanks for the help. I thought there would be django's official built in functionality which i might have missed, but looks like i have to use unofficial third party code. On Aug 14, 6:49 pm, Benjamin Wohlwendwrote: > Hi, > > On Aug 14, 8:54 pm,sniper wrote: > > > I am asking this because in the admin page, the list page uses digg > > style paging. > > Like everything else that comes with Django, the admin app is open > source, so nothing stops you from having a peek. This particular > functionality can be found in django/contrib/admin/templatetags/ > admin_list.py, line 28[1]. The template tag has some admin-specifics > in it, you'd have to copy the template tag and adjust it. Or, and this > is probably what David so eloquently suggested, you could use one of > the countless digg-style paginators for Django that float around the > net. I'm quite fond of this[2] one because it extends the built-in > pagination facilities instead of completely reinventing the wheel. > > Kind regards, > Benjamin > > [1]http://code.djangoproject.com/browser/django/trunk/django/contrib/adm... > [2]http://www.djangosnippets.org/snippets/773/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: send_mail function
For sending html I would rather do : from django.core.mail import EmailMessage from django.template import Context, loader t = loader.get_template('email.html') c = Context({'variable': variable,}) data = t.render(c) msg = EmailMessage("subjet", data, "sen...@foo.com", ["recipi...@bar.com"]) msg.content_subtype = "html" msg.send() Make a template named email.html and you can customize it with one or more variables. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom table instead of "user" in django
Here's what I did: I took the built in auth system and changed it a bit, or to be more precise I changed all imports within auth (because I moved it within the pythonpath) and edited models.py: http://dpaste.com/81651/ Whole code: http://www.ojii.ch/auth.tar.gz If you wanna use it: Add the folder in the archive to your pythonpath. Add 'auth' to your installed applications Set 'USER_MODEL' in your settings file to the model you use (string). Done. NOTE: I did NOT test this yet! Jonas PlanetUnknown wrote: > Guys, > I have a quick question. I am attracted to django due to its > flexibility however there is something bothering me now. > My question is can I use a custom table, say "consumer" instead of the > one provided my django ? > Here are the reasons - > 1.) I have my whole DB model around this consumer table and want to > keep it. > 2.) This table has a lot more fields than what the user has, which are > custom and uses the "email address" as the username. > > I know no. 2 has a solution of using a custom backend, but there are > so many out there that they confuse me. Also,I don't want to use the > "admin" part of django since I'll have a custom app. for that, but > which works on "consumer" > > I'm worried if I there is no way around using the django provided > "user" I'll have to re-invent the wheel, is that true ? e.g. session > management, etc. Not afraid of coding, but the whole reason I chose > django was to not do this. > > Any direction by the Gurus is appreciated. > Thanks. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how do you display custom permissions on admin site?
Ah thank you! I was also putting permissions inside BaseModel.Meta.permissions where BaseModel.Meta.abstract = True. When I put permissions inside MyModel.Meta.permissions, it showed up after flushing out and re-syncdb. I guess I will repeat permissions for each derived model class. Thank you again. Sam. On Mon, Aug 17, 2009 at 3:47 AM, fabrixwrote: > > On Aug 16, 2:29 pm, sam lee wrote: >> I run syncdb and runserver > [...] >> But I don't see the myapp | test_perm listed under Permissions field. > > permissions are stored in db, syncdb doesn't alter existing tables, so > your permission will not show up in your admin. > > As the Fu..Funny Maunal say: > > http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb > > "Syncdb will not alter existing tables > > syncdb will only create tables for models which have not yet been > installed. It will never issue ALTER TABLE statements to match changes > made to a model class after installation. Changes to model classes and > database schemas often involve some form of ambiguity and, in those > cases, Django would have to guess at the correct changes to make. > There is a risk that critical data would be lost in the process. > > If you have made changes to a model and wish to alter the database > tables to match, use the sql command to display the new SQL structure > and compare that to your existing table schema to work out the > changes. > " > > or.. you can try discarding the permission table and redo a syncdb, > but i can't assicure you that preexisting permissions assigned to > users will be conserved... > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: easy way of display an user bar?
On Aug 16, 9:31 am, Mirat Bayrakwrote: > I have that problem too, is there any other solution? Hi Mirat I'm not sure what problem you mean. Is the problem that you can't use RequestContext for some reason? Or is there another reason why you can't do it that way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django template language issue
On Mon, Aug 17, 2009 at 6:39 AM, Adoniswrote: > My problem is that even if the 'projects' queryset is empty, it still > includes the projects.html > Is there another way to do it? If you're using at least Django 1.1, you can use the empty tag: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-empty For example: {% for item in projects %} {% include projects.html %} {% empty %} There are no items in the project. {% endfor %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django template language issue
On Mon, Aug 17, 2009 at 5:39 AM, Adoniswrote: > My problem is that even if the 'projects' queryset is empty, it still > includes the projects.html > Is there another way to do it? Consult the documentation: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-empty -- "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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using custom table instead of "user" in django
Guys, I have a quick question. I am attracted to django due to its flexibility however there is something bothering me now. My question is can I use a custom table, say "consumer" instead of the one provided my django ? Here are the reasons - 1.) I have my whole DB model around this consumer table and want to keep it. 2.) This table has a lot more fields than what the user has, which are custom and uses the "email address" as the username. I know no. 2 has a solution of using a custom backend, but there are so many out there that they confuse me. Also,I don't want to use the "admin" part of django since I'll have a custom app. for that, but which works on "consumer" I'm worried if I there is no way around using the django provided "user" I'll have to re-invent the wheel, is that true ? e.g. session management, etc. Not afraid of coding, but the whole reason I chose django was to not do this. Any direction by the Gurus is appreciated. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django template language issue
Hi all, I am doing this {% for item in projects %} {% include projects.html %} {% endfor %} My problem is that even if the 'projects' queryset is empty, it still includes the projects.html Is there another way to do it? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django-tinymce and filebrowser, error.
Trevor, I've had problems with the same combination of tools. For me Popup windows are completely blank. But after adding document.domain as below I could get the popups to work but only in Firefox and Safari (I think). Updated yourApp/yourMediaFiles/js/tinymce/tiny_mce_popup.js for document.domain = 'yourdomain.com' to help with blank popup. Also same in Templates/admin/base.html. There is a post somewhere on the web that explains the exact details which I cannot find. A search should find it. This may be irrelevant but worth a try and in any case try different browsers to see if you get on better. Stuart On Aug 17, 6:23 am, tdelamwrote: > Hey, > > I built a web site locally, I am using django-tinyce and the django- > filebrowser, it works no problem on my local machine. As soon as I > deploy it to the server I have a problem. The TinyMCE is showing up > and working fine but when I click inside the image popup window to add > an image, I get an error: > > f is undefined > [Break on this error] return f.apply(s || t, Array.prototype.slice.call > (arguments, 1));\r\n - tiny_mce_src.js (line 9360) > > This line of code looks like this: > > return f.apply(s || t, Array.prototype.slice.call(arguments, 1)); > > i am not really sure why and how to even debug this. I am a stumped > because it works locally so I can't really tell where to go from here. > Any suggestions? > > Trevor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin problems with the docu
hi now it works, i think i only had to restart my computer, doessent know why, but it works thanks to all --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
site and username unique together
Hi! I am working on a project with multiple sites and are using the contrib.site app to separate them from eachother. The number of sites will be high and changing often, so I don't want to modify the Apache config and create a new VirtualHost/Location for each new site. I have solved this by writing a middleware that parses the url and changes the settings.SITE_ID based on that. Similar to http://www.djangosnippets.org/snippets/1099/ I'm planing to use contrib.auth for user login on each site, but I want to make the username unique together with the site. I tried something like this: class SiteUser(User): site = ForeignKey(Site) class Meta: unique_together = (('site', 'username'),) But this will not work so well, since the username field has to be in the same model as the unique_together meta attribute, and the username field is still unique across the sites. So I tried to make the User model abstract and removing the unique flag: User._meta.abstract = True User._meta.get_field('username')._unique = False But now the ManyToMany fields in User will complain that it's a abstract class, wich makes sence. And I guess you shouldn't modify en existing model anyway. Is it possible to do what I am trying to do without writing a new auth app? Are there any other problems with the multi site approach? /Fredrik --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin problems with the docu
hi now it works, i think i only had to restart my computer, doessent know why, but it works thanks to all --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Eric Evans Value Objects
I'm looking for a support for something like Eric Evans Value Objects (http://domaindrivendesign.org/). For example, if I have a Person model like class Adress(models.Model): street = ... city = ... postal_code = ... class Person(models.Model): home_adress = models.OneToOneField(Adress) business_adress = models.OneToOneField(Adress) Adress is like a Value Object, but I don't want any adress table, nor extra foreign key and database joins. My application is not made for a National Post Office domain. I just want an Adress class whitout database identity. Another possibility I know is define a custom Field Type, but this one seems a too difficult solution for such a simple task. Especially if Adress is made form simple and obvious attributes. If Person has only one Adress attribute, the inheritance likes such a good solution, but if I want a second Adress, or I want an Adress with null=True, inheritance si bad. Can you give me some suggestions, how to implement Eric Evans's Value Objects in Django? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to extend Auth/User in admin view?
On Aug 17, 8:06 am, Léon Dignònwrote: > Hello, > > I use an extended User Model and like to display these fields in the > admin view at Auth/User. Can anybody show me how this works? > > Thanks > > -LD Create your own admin class for your extended User model, inheriting from the one in contrib.auth.admin. Then unregister the default one and register yours: from django.contrib.auth.admin import UserAdmin class MyUserAdmin(UserAdmin(UserAdmin): extended attributes here ... try: admin.site.unregister(User) except except admin.sites.NotRegistered: pass admin.site.register(User, MyUserAdmin) -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and stackless python
Great! Thanks! No idea how im gonna do that since i have no idea where/how to get that source code and do it, but at least i know what to do. Alan. On Aug 17, 1:44 am, Graham Dumpletonwrote: > On Aug 16, 10:43 pm, zayatzz wrote: > > > apparently installing mod_wsgi was not the instant get out of trouble > > card. > > > For a while i had problem with mod_wsgi settings. Now the trouble with > > modules continues. I think i must somehow finally fix all the paths. > > > current error is : > > [Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1] raise > > ImproperlyConfigured("Error loading MySQLdb module: %s" % e) > > [Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1] > > ImproperlyConfigured: Error loading MySQLdb module: No module named > > MySQLdb > > Nothing to do with paths. You simply have to install the MySQLdb > module from source code for that specific Python installation. You > can't have it use copy from another Python installation. > > Graham > > > > > Alan > > > On Aug 16, 2:56 pm, zayatzz wrote: > > > > z...@zayatzz:/var/log/apache2$ ls -las /usr/local/lib/python2.6/site- > > > packages > > > total 27 > > > 0 drwxrwsr-x 3 root staff 144 2009-08-16 12:09 . > > > 19 drwxrwsr-x 26 root staff 19392 2009-08-16 10:54 .. > > > 1 drwxr-sr-x 17 root staff 496 2009-08-16 12:09 django > > > 4 -rw-r--r-- 1 root staff 947 2009-08-16 12:09 Django-1.1- > > > py2.6.egg-info > > > 4 -rw-r--r-- 1 root staff 119 2009-08-16 10:53 README > > > > I reinstalled it with ubuntu's aptitude. So as i get it,. i should > > > recompile mod_python > > > > I was thinking about using mod_wsgi myself... > > > > I'll investigate mod_wsgi setup. > > > > Should i keep something in mind now that i have stackless instead of > > > regular python? > > > > Alan. > > > > On Aug 16, 2:37 pm, Graham Dumpleton > > > wrote: > > > > > On Aug 16, 9:24 pm, zayatzz wrote: > > > > > > I did reinstall mod_python indeed. > > > > > Then you can't have installed it for that version of Python. Did you > > > > use the --with-python option to 'configure' for mod_python to tell it > > > > to use your alternate Python installation? That or the installed > > > > mod_python is not readable to the user that Apache runs as. What do > > > > you get for: > > > > > ls -las /usr/local/lib/python2.6/site-packages > > > > > You might want to also consider using mod_wsgi instead as simpler to > > > > get working than mod_python. > > > > > Graham > > > > > > when i do import mod_python then : > > > > > > >>> import mod_python > > > > > > Traceback (most recent call last): > > > > > File "", line 1, in > > > > > ImportError: No module named mod_python > > > > > > so nope :( > > > > > > Alan > > > > > > On Aug 16, 2:01 pm, Graham Dumpleton > > > > > wrote: > > > > > > > Did you actually bother to reinstall mod_python after you nuked your > > > > > > original Python installation. Likely when reinstalling it you lost > > > > > > everything that was in prior site-packages and so are missing the > > > > > > Python module component bits of mod_python, ie., no longer > > > > > > installed. > > > > > > > If from command line stackless Python you go: > > > > > > > import mod_python > > > > > > > does it actually find the module? > > > > > > > Graham > > > > > > > On Aug 16, 8:51 pm, zayatzz wrote: > > > > > > > > i begun to think about the same thing when i went through the log. > > > > > > > > Couldnt find anything useful why mod_python is failing atm, so i > > > > > > > anyone can think of why this is not working - i still could use > > > > > > > your > > > > > > > help. Otherwise since it has nothing to do with django, i'll try > > > > > > > to > > > > > > > get help though stackoverflow and google :) > > > > > > > > Alan > > > > > > > > On Aug 16, 1:19 pm, Austin Gabel wrote: > > > > > > > > > It looks like the issue is occurring when Apache tries to load > > > > > > > > mod_python. > > > > > > > > This doesn't have anything to do with Django at this point. > > > > > > > > You may need to > > > > > > > > do a bit more research on how Stackless Python works with > > > > > > > > Apache and > > > > > > > > mod_python. > > > > > > > > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz > > > > > > > > wrote: > > > > > > > > > > apache error log shows such stuff: > > > > > > > > > >http://dpaste.com/81241/ > > > > > > > > > > Alan. > > > > > > > > > > On Aug 16, 12:12 pm, zayatzz > > > > > > > > > wrote: > > > > > > > > > > Hello > > > > > > > > > > > I installed stackless pyton 2.6.2 after reading several > > > > > > > > > > sites that > > > > > > > > > > said its fully compatible with vanilla python. After > > > > > > > > > > installing i > > > > > > > > > > found
Re: how do you display custom permissions on admin site?
On Aug 16, 2:29 pm, sam leewrote: > I run syncdb and runserver [...] > But I don't see the myapp | test_perm listed under Permissions field. permissions are stored in db, syncdb doesn't alter existing tables, so your permission will not show up in your admin. As the Fu..Funny Maunal say: http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb "Syncdb will not alter existing tables syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process. If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes. " or.. you can try discarding the permission table and redo a syncdb, but i can't assicure you that preexisting permissions assigned to users will be conserved... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using glovar vars
For what you describe, you're not looking for "global" variables in the sense that you want some value persisted in the same process. You're looking at session variables, which are variables persisted for a specific user session. See: http://docs.djangoproject.com/en/dev/topics/http/sessions/ Honestly though, the easiest way that I can think of is just to use separate URLs. That way, a user could easily use the PC version if he desires. -- dz On Mon, Aug 17, 2009 at 3:28 AM, Steve Patrickwrote: > > I`ve got an application developed for PCs and I want to make it > available for mobile devices. There are only some slight differences > between booth two versions, so I think is not worth while to develope > different applications. Instead, I've decided to develope an only > application in which I need a "global" variable that helps me to > remember if the user is using a mobile device or a PC (I know it on my > firts page, looking at the user agent). How can I store that > variable?? Of course, if different users connect to the application > they would have different user agents and thus, different values for > that "global" variable I want to use. > Thanks for your time > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using glovar vars
I`ve got an application developed for PCs and I want to make it available for mobile devices. There are only some slight differences between booth two versions, so I think is not worth while to develope different applications. Instead, I've decided to develope an only application in which I need a "global" variable that helps me to remember if the user is using a mobile device or a PC (I know it on my firts page, looking at the user agent). How can I store that variable?? Of course, if different users connect to the application they would have different user agents and thus, different values for that "global" variable I want to use. Thanks for your time --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to extend Auth/User in admin view?
Hello, I use an extended User Model and like to display these fields in the admin view at Auth/User. Can anybody show me how this works? Thanks -LD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with getting setting up apache server for django
On Aug 17, 4:33 pm, Graham Dumpletonwrote: > On Aug 17, 2:43 pm, NiJoMi wrote: > > > Done a reinstall and checked each step. > > --- > > Step 1: Installed WampServer2 and verified working > > Location: C:\imfree > > Components of WampServer 2.0i [11/07/09] > > Apache 2.2.11 > > MySQL 5.1.36 > > PHP 5.3.0 > > --- > > Step 2: Set up test enviroment > > Created following folders > > E:\localhost > > E:\Django\djangotest > > E:\Django\testsite2 > > placed unique index.html in each folder > > edited hosts: > > added > > 127.0.0.1 djangotest.lc > > 127.0.0.1 testsite2.lc > > --- > > Step 3: Set up Virtual Hosts > > Edits to files: > > > httpd.conf: > > # Uncommented following > > # Virtual hosts > > Include conf/extra/httpd-vhosts.conf > > > > http-vhosts.conf: > > # Virtual Hosts > > # > > # Use name-based virtual hosting. > > # > > NameVirtualHost *:80 > > # > > > > ServerAdmin webmas...@djangotest.lc > > DocumentRoot "E:/Django/djangotest" > > ServerName djangotest.lc > > ServerAliaswww.djangotest.lc > > ErrorLog "logs/djangotest.lc-error.log" > > CustomLog "logs/djangotest.lc-access.log" common > > > > Order allow,deny > > Allow from all > > > > > > > > > ServerAdmin webmas...@testsite2.lc > > DocumentRoot "E:/Django/testsite2" > > ServerName testsite2.lc > > ServerAliaswww.testsite2.lc > > ErrorLog "logs/testsite2.lc-error.log" > > CustomLog "logs/testsite2.lc-access.log" common > > > > Order allow,deny > > Allow from all > > > > > > > > > ServerAdmin webmas...@dummy-host2.localhost > > DocumentRoot "E:/localhost" > > ServerName localhost > > ErrorLog "logs/localhost-error.log" > > CustomLog "logs/localhost-access.log" common > > > > Order allow,deny > > Allow from all > > > > > > Started server [ :) Working] > > Stopped server > > --- > > Step 4: Installed Python 2.6.2 > > Location: C:\imfree\bin [keeping things tidy] > > tested and verified working by the following methods > > 1. Start>All Programs>Python 2.6>python [ :) Working] > > 2. Start>Run>CMD > > >cd C:\imfree\bin\Python26 > > C:\imfree\bin\Python26>python [ :) Working] > > --- > > Step 5. Install Django SVN > > Location: C:\imfree\bin\Python26\Lib\site-packages\django > > copied django-admin.py to C:\imfree\bin\Python26\Tools\Scripts > > Tested by first deleting folder E:\Django\djangotest > > then: > > 1. Start>All Progams>Python 2.6>python > > entered import django into Python command line Result no > > errors. > > > 2. Start>Run>CMD > > >E: > > E:\>cd DJango > > E:\Django>django-admin.py startproject djangotest > > 'django-admin.py' is not recocognised as an internal or > > external > > command, > > operable program or batch file. [ :( missing path?. use > > set_path.] > > E:\Django>set > > path=%path%;C:\imfree\bin\Python26\Tools\Scripts [path > > to django-admin.py] > > E:\Django>django-admin startproject djangotest > > E:\Django>cd djangotest > > E:\Django\djangotest>python manage.py runserver > > 'python' is not recocognised as an internal or external > > command, > > operable program or batch file. [ :( missing path?. use > > set_path.] > > E:\Django\djangotest>set path=%path%;C:\imfree\bin\Python26 > > [path to > > python] > > E:\Django\djangotest>python manage.py runserver > > Validating models... > > 0 errors found > > > Django version 1.2 pre-alpha SVN-11464, using settings > > 'djangotest.settings' > > Development server is running athttp://127.0.0.1:800/ > > Quit the server with CTRL-BREAK. [ :)
Re: are model field choices enumerated in the db?
On Aug 17, 6:28 am, cerberoswrote: > when the choices attribure is used for a model field are the choices > enumerated in the database? No. -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with getting setting up apache server for django
On Aug 17, 2:43 pm, NiJoMiwrote: > Done a reinstall and checked each step. > --- > Step 1: Installed WampServer2 and verified working > Location: C:\imfree > Components of WampServer 2.0i [11/07/09] > Apache 2.2.11 > MySQL 5.1.36 > PHP 5.3.0 > --- > Step 2: Set up test enviroment > Created following folders > E:\localhost > E:\Django\djangotest > E:\Django\testsite2 > placed unique index.html in each folder > edited hosts: > added > 127.0.0.1 djangotest.lc > 127.0.0.1 testsite2.lc > --- > Step 3: Set up Virtual Hosts > Edits to files: > > httpd.conf: > # Uncommented following > # Virtual hosts > Include conf/extra/httpd-vhosts.conf > > http-vhosts.conf: > # Virtual Hosts > # > # Use name-based virtual hosting. > # > NameVirtualHost *:80 > # > > ServerAdmin webmas...@djangotest.lc > DocumentRoot "E:/Django/djangotest" > ServerName djangotest.lc > ServerAliaswww.djangotest.lc > ErrorLog "logs/djangotest.lc-error.log" > CustomLog "logs/djangotest.lc-access.log" common > > Order allow,deny > Allow from all > > > > > ServerAdmin webmas...@testsite2.lc > DocumentRoot "E:/Django/testsite2" > ServerName testsite2.lc > ServerAliaswww.testsite2.lc > ErrorLog "logs/testsite2.lc-error.log" > CustomLog "logs/testsite2.lc-access.log" common > > Order allow,deny > Allow from all > > > > > ServerAdmin webmas...@dummy-host2.localhost > DocumentRoot "E:/localhost" > ServerName localhost > ErrorLog "logs/localhost-error.log" > CustomLog "logs/localhost-access.log" common > > Order allow,deny > Allow from all > > > Started server [ :) Working] > Stopped server > --- > Step 4: Installed Python 2.6.2 > Location: C:\imfree\bin [keeping things tidy] > tested and verified working by the following methods > 1. Start>All Programs>Python 2.6>python [ :) Working] > 2. Start>Run>CMD > >cd C:\imfree\bin\Python26 > C:\imfree\bin\Python26>python [ :) Working] > --- > Step 5. Install Django SVN > Location: C:\imfree\bin\Python26\Lib\site-packages\django > copied django-admin.py to C:\imfree\bin\Python26\Tools\Scripts > Tested by first deleting folder E:\Django\djangotest > then: > 1. Start>All Progams>Python 2.6>python > entered import django into Python command line Result no > errors. > > 2. Start>Run>CMD > >E: > E:\>cd DJango > E:\Django>django-admin.py startproject djangotest > 'django-admin.py' is not recocognised as an internal or > external > command, > operable program or batch file. [ :( missing path?. use > set_path.] > E:\Django>set > path=%path%;C:\imfree\bin\Python26\Tools\Scripts [path > to django-admin.py] > E:\Django>django-admin startproject djangotest > E:\Django>cd djangotest > E:\Django\djangotest>python manage.py runserver > 'python' is not recocognised as an internal or external > command, > operable program or batch file. [ :( missing path?. use > set_path.] > E:\Django\djangotest>set path=%path%;C:\imfree\bin\Python26 > [path to > python] > E:\Django\djangotest>python manage.py runserver > Validating models... > 0 errors found > > Django version 1.2 pre-alpha SVN-11464, using settings > 'djangotest.settings' > Development server is running athttp://127.0.0.1:800/ > Quit the server with CTRL-BREAK. [ :) Working] You should not install Django site instance under DocumentRoot. If you stuff up your Apache configuration at some point, your source code would be downloadable, including any passwords in settings.py file. So, keep them separate. > 3. Test with built in server > edited
Re: Success at using "reusable apps"?
On Mon, Aug 17, 2009 at 3:41 PM, Andy McKaywrote: > > > On 16-Aug-09, at 8:50 PM, Margie Roginski wrote: > > * modify the threadedcomments views.py code to take a callback > > function as an argument - that callback function could do my Task > > specific stuff as described above, but this would keep it more > > encapsulated within my Task app (but of course I would still have to > > modify threadecomments to take the callback arg) > > Or sounds like you could write a signal in your own code. Wow. I never thought of that Andy. Thanks for sharing! -- http://blog.scrum8.com http://twitter.com/scrum8 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---