Re: django foreignkey
manage.py syncdb won't add new fields to the database if the table already exists. You'll have to do this yourself. See manage.py sqlall for some help. Otherwise, if you have: user = models.ForeignKey(User), then look for a field named user_id in your table. Nathan Ostgard On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > I have a model with a field models.ForeignKey(), with manage.py > validate I check if my code are right, then run manage.py syncdb. When > I was checking the tables generated I don't see any foreign key > created? Is there something wrong? where should I check? > > I am using django 0.96, mysql 5 on winxp > > Thanks > james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple URLconfs per app?
If you just want to specify the urls as listed, you could always create a urls folder in myapp, put an __init__.py in there, and create myapp/urls/feature1.py and myapp/urls/feature2.py. Nathan Ostgard On Jul 18, 7:37 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > You'll need two files. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I know if fastcgi is installed correctly? (using dreamhost)
On DreamHost, in ~/mydomain.com I have two files: 1. dispatch.fcgi #!/home/myusername/python/bin/python import os import sys from django.core.servers.fastcgi import runfastcgi sys.path += ['/home/myusername/django'] os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' runfastcgi(['method=threaded', 'daemonize=false']) 2. .htaccess (this is what you use to tell Apache to enable mod_rewrite, note the . before the name) AddHandler fastcgi-script .fcgi RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L] In my case, I have my Django projects/apps installed under ~/django, and my Virtual Python installation in ~/python. Nathan Ostgard On Jul 18, 9:54 am, walterbyrd <[EMAIL PROTECTED]> wrote: > I am trying to follow jeff croft's tutorial for installing django on > dreamhost. > > http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/ > > I am trying to "Install and configure FastCGI" > > I followed the tutorial, I don't see where I did anything wrong. > > One part that I don't quite understand: > > --- > Set up mod_rewrite > Apache's mod_rewrite module will pass all requests to your website > through dispatch.fcgi, and thus, into Django's URL dispatcher. > > > How I am I supposed to do that? Is that done when I do the pkill > python? > > After the pkill python, the tutorial states: > > --- > All URLs on our subdomain should now be routed to Django. Feel free to > open up your browser and try it out for yourself. > --- > > So, I don't have to restart python? Also, what am I supposed to see, > if the setup was successful? I gave it a try and the server timed out. > Any idea what I did wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing FK sets in model methods
Correct. I over looked a few basics. On 19 יולי, 04:58, "Ben Ford" <[EMAIL PROTECTED]> wrote: > This error message is to do with a syntax error... It doesn't have anything > to do with django specifically. If you've cut and pasted verbatim, then you > need a colon ( : ) at the end of your if > 0 line. This is what python > is flagging as an error as far as i can see. > Ben > > On 18/07/07, Ilan <[EMAIL PROTECTED]> wrote: > > > > > > > You're correct I did have a extra space, but the original problem was > > syntax error on the following line : > > if self.segment_set.count() > 0 > > so my question is : can I acess to FK queryset as described in > >http://www.djangoproject.com/documentation/db-api/#Backwardin a model > > method > > > thanks > > > On 18 יולי, 17:32, Tim Chase <[EMAIL PROTECTED]> wrote: > > > > Can someone point me to the problem? > > > > > class Base(models.Model): > > > > User = models.CharField(maxlength=200) > > > > Notes = models.CharField(maxlength=200) # free text > > > > > def _first_date(self): > > > >""" Return the first date """ > > > > if self.segment_set.count() > 0 > > > > return(self.segment_set.order_by('create_date') > > > > [0].create_date) > > > > first_date = property(_first_date) > > > > > class Segment(models.Model): > > > > base = models.ForeignKey(Base) > > > > create_date = models.DateTimeField(auto_now_add=True) > > > > update_date = models.DateTimeField(auto_now=True) > > > > Notes = models.CharField(maxlength=200) # free tex > > > > > # > > > > D:\Sites\mysite>python manage.py syncdb > > > > Error: Couldn't install apps, because there were errors in one or more > > > > models: > > > > mysite.traveler: invalid syntax (models.py, line 8) > > > > If you did a copy&paste of your actual code, line #8 ("def > > > _first_date(self):") seems to have an extra space worth of > > > indentation from the User/Notes lines. > > > > Python would flag this as bogus, which in turn would likely > > > trigger an error in validation. > > > > -tim > > -- > Regards, > Ben Ford > [EMAIL PROTECTED] > +628111880346 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Synchronising Database.
On 19-Jul-07, at 11:08 AM, Dmitriy Sodrianov wrote: > How should the process of synchronisation be performed? > To my mind only dropping table and recreating it should do the task. for example: http://www.djangosnippets.org/snippets/188/ -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Synchronising Database.
On 7/19/07, Dmitriy Sodrianov <[EMAIL PROTECTED]> wrote: > After typing manage.py syncdb again the table is not synchronised with > the model despite the name of the command syncdb. http://www.djangoproject.com/documentation/django-admin/#syncdb > How should the process of synchronisation be performed? > To my mind only dropping table and recreating it should do the task. You'll want to look up the appropriate syntax for "ALTER TABLE" for the database you're using. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Synchronising Database.
Hi to all! Imagine a situation when a Django model is installed into the database with well-known command manage.py syncdb and then it is altered, let's say a new field is added to model. After typing manage.py syncdb again the table is not synchronised with the model despite the name of the command syncdb. How should the process of synchronisation be performed? To my mind only dropping table and recreating it should do the task. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django foreignkey
hi, I have a model with a field models.ForeignKey(), with manage.py validate I check if my code are right, then run manage.py syncdb. When I was checking the tables generated I don't see any foreign key created? Is there something wrong? where should I check? I am using django 0.96, mysql 5 on winxp Thanks james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem installing django on dreadhost
I think I may have fixed it. I did the following: 1) I had moved sqlite, but didn't change the link, so I fixed that. 2) In the settings.py, I entered a path to the database, but not the actual database name, so I fixed that as well. 3) Then I re-ran the django-admin.py syncdb script $ django-admin.py syncdb Creating table auth_message Creating table auth_group Creating table auth_user Creating table auth_permission Creating table django_content_type Creating table django_session Creating table django_site You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): yes Please enter either "yes" or "no": yes Username (Leave blank to use 'username'): E-mail address: [EMAIL PROTECTED] Password: Password (again): Superuser created successfully. Installing index for auth.Message model Installing index for auth.Permission model Loading 'initial_data' fixtures... No fixtures found. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: context processor question
Hi Jeremy, I am a bit lost ... where do I apply that? Isn't that I just call the variable name/dict key in the template? Thanks james On Jul 19, 11:18 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote: > ... > > > the commonly use data will automatically available, do I get it right? > > Yes. Just keep in mind that you need to use RequestContext rather > than Context in order for context processors to be applied. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
It's easy to write a "basic" blog in Django. If that's all people want, then great. Something like that will work perfectly for the majority of bloggers (who probably won't get that much readership anyway)... But all this talk about making a "full-featured" blog app in Django -- one that will really get noticed (and thus get django noticed): what we need is a blog with *more features* that could actually begin to compete with something like Wordpress**. I mean stuff like Akismet, Flickr integration, delicious/magnolia bookmarks, multi-author (with per-object permissions), importing from Wordpress, statistics, easy web-based installation (NOT easy_install but a wizard someone could follow, like the Wordpress install, lots of customization, integration with pingback services, etc. If that sounds like a lot, that's because it is. To even be a blip on the screen it will need this kind of stuff. I also doubt the django- admin will be sufficient for an application like this. I know a lot of the stuff I've mentioned above has already been hammered out by djangonauts -- I'm sure a snippet for almost every feature has been posted on djangosnippets.org. It's a matter of bringing all those together into something that works out of the box, rather than everyone patching together their own frankenstein. ** By the way, I know "competing with Wordpress" is nearly impossible. I'm just saying that to accomplish what it sounds like people here are talking about, we need close to the same level of functionality. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with multiple django versions on mod_python
On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote: > > Please, if you've seen the same issue or have any helpful ideas to try > to stop the error, let me know. I think I've seen the same problem (or, at least, an analogous one). Unfortunately, I can't provide much by way of helpful debug or solution - the sysadmin that identified the problem for us isn't around for me to ask him for more details. As I recall, the problem was mod_python. Older versions of mod_python had some sort of issue with caching python instances. As a result, if you deployed two different versions of Django, the version of Django that was provided to a given request was determined by the thread that served the request. If the first request served by a thread used the old version of Django, that was the version that was used for all subsequent requests on that thread, regardless of the version that was required to satisfy the request. I believe we fixed the problem by updating mod_python, but I'm not completely certain on that. I know that this is all vague and ambiguous help - sorry I can't be more specific. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with multiple django versions on mod_python
I've run into a problem that appears to be caused by multiple django versions running on the same server. I have a preforked mod_python installation and the problem I'm seeing is this: after using the trunk- based application, I try to use the 0.91-based application and get a 500 error. The root of the SQL error is that variables aren't quoted properly and it can't find a column name, which you can see if you look at the SQL that is printed out. Here's an example of the error: ERROR: column "activity" does not exist SELECT "packages"."label","packages"."name" FROM "packages" WHERE "packages"."label" = activity ORDER BY "packages"."name" ASC Looking at the variables, the params list contains a unicode variable - which I don't think will work okay in 0.91: params [u'activity'] The error occurs only after I have visited the trunk-based application. If I restart the server, I can use the 0.91-based application continuously. Looking in log files I have seen that the 500 error occurs after somebody has used the trunk-based application, plus the error has only showed up after I deployed the trunk-based application in the last week or so. I thought this problem would be avoided by using the PythonInterpreter option, but it hasn't worked so far. Here are my Location directives from my testing server (which also reproduces the problem): SetHandler mod_python PythonPath "['/opt/djangolibs/django_src','/djangoapps'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE sc_ca.settings PythonInterpreter sc_ca PythonDebug On SSLRequireSSL SetHandler mod_python PythonPath "['/opt/djangolibs/django_trunk','/djangoapps'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE syb.noisy.settings PythonInterpreter curriculum PythonDebug On SSLRequireSSL The directories django_src is the 0.91 tree, django_trunk is obviously trunk, and I don't have a link to either in site-packages. I've removed *.pyc files in all the trees but this only delays the problem until the files are regenerated. Please, if you've seen the same issue or have any helpful ideas to try to stop the error, let me know. Thanks! -rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use request.GET??
On 7/18/07, Greg <[EMAIL PROTECTED]> wrote: > Do I have to return a HttpResponse? Yes. It is an error for an HTTP Request not to be given a HTTP response in return. In the 'if "favorite_color"' branch of your example view, simple "return response" just before the else: clause. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: context processor question
On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote: ... > the commonly use data will automatically available, do I get it right? > Yes. Just keep in mind that you need to use RequestContext rather than Context in order for context processors to be applied. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
context processor question
Hi, As I understand context are data we can use in our templates, and the purpose of context processor is instead of doing something like c = Context({ 'latest_poll_list': latest_poll_list, }) or return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list}) the commonly use data will automatically available, do I get it right? Thanks james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django's User authentication
Thanks Jason for sharing this one. cheers, james On Jul 18, 9:07 pm, [EMAIL PROTECTED] (Jason F. McBrayer) wrote: > james_027 <[EMAIL PROTECTED]> writes: > > what if I need additional fields or methods for my apps? Do i inherit > > it or edit the user class? > > The standard approach is > here:http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model > > However, also have a look at this > approach:http://groups.google.com/group/django-developers/browse_thread/thread... > > It does require writing a context processor and a middleware, but they > are very small and simple, and they greatly simplify the use of your > user object in your views and templates. > > -- > +---+ > | Jason F. McBrayer[EMAIL PROTECTED] | > | If someone conquers a thousand times a thousand others in | > | battle, and someone else conquers himself, the latter one | > | is the greatest of all conquerors. --- The Dhammapada| --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use request.GET??
Also, when I use 'http://example.com/url_to_set_colour_view/? favorite_color=Blue' it gives me an error that says: 'The view mysite.rugs.views.set_color didn't return an HttpResponse object.' Do I have to return a HttpResponse? My view is shown above...if the 'if' statement is true the view doesn't return anything. Thanks for any help On Jul 18, 9:44 pm, Greg <[EMAIL PROTECTED]> wrote: > I've seen other Django websites that use the ? mark at the end. I've > always wondered what the reason for that was. So the only time the ? > mark is used is to send form data? > > On Jul 18, 9:33 pm, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote: > > > On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote: > > > > On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote: > > > > I was wondering how do I send a 'favorite_color' GET parameter? Do I > > > > have to use a form to do this that sends data by GET or is there > > > > another way to do it? > > > >http://example.com/url_to_set_colour_view/?favorite_color=Blue > > > Also be sure to URL encode any characters in the paramter that require > > it. See section 2.2 of RFC1738. > > >http://www.ietf.org/rfc/rfc1738.txt > > -- > > _nimrod_a_abing_ > > >http://abing.gotdns.com/http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use request.GET??
I've seen other Django websites that use the ? mark at the end. I've always wondered what the reason for that was. So the only time the ? mark is used is to send form data? On Jul 18, 9:33 pm, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote: > On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote: > > > > > On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote: > > > I was wondering how do I send a 'favorite_color' GET parameter? Do I > > > have to use a form to do this that sends data by GET or is there > > > another way to do it? > > >http://example.com/url_to_set_colour_view/?favorite_color=Blue > > Also be sure to URL encode any characters in the paramter that require > it. See section 2.2 of RFC1738. > > http://www.ietf.org/rfc/rfc1738.txt > -- > _nimrod_a_abing_ > > http://abing.gotdns.com/http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
Also, this library is really simple to use to pull data out of excel. http://www.lexicon.net/sjmachin/xlrd.htm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ip to location
Francesco, MaxMind(R) produces commercial and free IP geolocation datasets. As a proof of concept I created GeoDjango-enabled models and import scripts for their CSV files: http://www.djangosnippets.org/snippets/327/ http://www.djangosnippets.org/snippets/328/ To create this code I had to patch Django since it lacks large integer support; specifically, IP address queries require conversion to a long integer. I used Peter Nixon's latest patch to get BigIntegerField: http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch I'm not sure about the utility of including it in GeoDjango. The large database size (3 million rows for LocationBlock), makes queries slower -- however, there are much fewer CountryBlock rows. I will try out their C API and compare. This may be useful for some research purposes (e.g. how many IP allocations within a political boundary, etc.). Example: >>> from geoip.models import LocationBlock, CountryBlock >>> lb = LocationBlock.objects.ipquery('72.14.207.99') >>> print unicode(lb.location) Location 2633: United States - CA, Mountain View 94043 >>> print lb.location.point POINT (-122.05740012 37.41919965) >>> cb = CountryBlock.objects.ipquery('66.64.46.23') >>> print unicode(cb.location) United States: 66.60.64.0 to 66.70.70.109 -Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple URLconfs per app?
You'll need two files. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use request.GET??
On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote: > > On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote: > > I was wondering how do I send a 'favorite_color' GET parameter? Do I > > have to use a form to do this that sends data by GET or is there > > another way to do it? > > http://example.com/url_to_set_colour_view/?favorite_color=Blue Also be sure to URL encode any characters in the paramter that require it. See section 2.2 of RFC1738. http://www.ietf.org/rfc/rfc1738.txt -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use request.GET??
On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote: > I was wondering how do I send a 'favorite_color' GET parameter? Do I > have to use a form to do this that sends data by GET or is there > another way to do it? http://example.com/url_to_set_colour_view/?favorite_color=Blue --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to use request.GET??
Hello, I have the following function / def set_color(request): if "favorite_color" in request.GET: # Create an HttpResponse object... response = HttpResponse("Your favorite color is now %s" % \ request.GET["favorite_color"]) # ... and set a cookie on the response response.set_cookie("favorite_color", request.GET["favorite_color"]) else: return HttpResponse("You didn't give a favorite color.") / I was wondering how do I send a 'favorite_color' GET parameter? Do I have to use a form to do this that sends data by GET or is there another way to do it? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple URLconfs per app?
I'm a little fuzzy on how Django imports additional app URLconfs. I've got two parts of an app that are closely related to one another, however I'd like to give them both root URLs. myproject/urls.py:: urlpatterns = patterns('', (r'^feature1/', include('myproject.apps.myapp.urls')), (r'^feature2/', include('myproject.apps.myapp.urls')), ) Is there a way to group the URLs in the app's urls.py so as to keep them all in that one file? Or do I *have* to make seperate files (e.g. feature1_urls.py, feature2_urls.py)? myproject/urls.py:: urlpatterns = patterns('', (r'^feature1/', include('myproject.apps.myapp.urls.feature1')), (r'^feature2/', include('myproject.apps.myapp.urls.feature2')), ) - whiteinge --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to custom group models in the admin panel?
I just opened a ticket for this. http://code.djangoproject.com/ticket/4918 Sebastian Macias On Jul 12, 6:37 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/12/07,SebastianMacias <[EMAIL PROTECTED]> wrote: > > > > > By default models are grouped by app. I really need to be able to > > break down that grouping a little bit more. I will have an app with > > probably 40-50 models and would like togroupthose logically instead > > of having them all listed under my app name. > > This isn't possible at present. You can collect the fields on an > individual model into groups, but there isn't currently a mechanism > togroupmodels other than by application. > > It is an interesting idea though. I would suggestion opening a ticket > requesting this feature - we are currently rewriting the admin views > to use newforms. This particular feature probably won't be a target > for the initial release, but its worth documenting it to make sure we > don't code ourselves into a corner. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Modifying Model Field Attributes on Run Time
On Wed, 2007-07-18 at 17:08 +, Sebastian Macias wrote: > Is there anyway to modify model field attributes on run time.. What > I'm trying to do is to build some logic that will decide whether a > model that is related to other model should be edited or not inline in > the admin. > > Basically: "client = models.ForeignKey(Client, unique=True, > edit_inline = True, core=True)" should be changed to client = > models.ForeignKey(Client, unique=True, edit_inline = False) on run > time. It should be possible, if you're careful (entirely unsupported, though, so if it breaks you get to keep both pieces). After a model class has been parsed at import time, all the information about the Field classes resides in the _meta attribute, which is an Options class from django/db/models/options.py. The fields themselves are all subclasses of Field, which is in django/db/models/fields/__init__.py. Both of those files are fairly well documented in the comments, so it should be fairly straightforward to read through the Field class (as a starting point) to work out what you need to change. Regards, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing FK sets in model methods
This error message is to do with a syntax error... It doesn't have anything to do with django specifically. If you've cut and pasted verbatim, then you need a colon ( : ) at the end of your if > 0 line. This is what python is flagging as an error as far as i can see. Ben On 18/07/07, Ilan <[EMAIL PROTECTED]> wrote: > > > You're correct I did have a extra space, but the original problem was > syntax error on the following line : > if self.segment_set.count() > 0 > so my question is : can I acess to FK queryset as described in > http://www.djangoproject.com/documentation/db-api/#Backward in a model > method > > thanks > > On 18 יולי, 17:32, Tim Chase <[EMAIL PROTECTED]> wrote: > > > Can someone point me to the problem? > > > > > class Base(models.Model): > > > User = models.CharField(maxlength=200) > > > Notes = models.CharField(maxlength=200) # free text > > > > > def _first_date(self): > > >""" Return the first date """ > > > if self.segment_set.count() > 0 > > > return(self.segment_set.order_by('create_date') > > > [0].create_date) > > > first_date = property(_first_date) > > > > > class Segment(models.Model): > > > base = models.ForeignKey(Base) > > > create_date = models.DateTimeField(auto_now_add=True) > > > update_date = models.DateTimeField(auto_now=True) > > > Notes = models.CharField(maxlength=200) # free tex > > > > > # > > > D:\Sites\mysite>python manage.py syncdb > > > Error: Couldn't install apps, because there were errors in one or more > > > models: > > > mysite.traveler: invalid syntax (models.py, line 8) > > > > If you did a copy&paste of your actual code, line #8 ("def > > _first_date(self):") seems to have an extra space worth of > > indentation from the User/Notes lines. > > > > Python would flag this as bogus, which in turn would likely > > trigger an error in validation. > > > > -tim > > > > > -- Regards, Ben Ford [EMAIL PROTECTED] +628111880346 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Modifying Model Field Attributes on Run Time
Is there anyway to modify model field attributes on run time.. What I'm trying to do is to build some logic that will decide whether a model that is related to other model should be edited or not inline in the admin. Basically: "client = models.ForeignKey(Client, unique=True, edit_inline = True, core=True)" should be changed to client = models.ForeignKey(Client, unique=True, edit_inline = False) on run 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cheetah-like comments [was: Re: template preprocessor ?]
Thank you James, it's really great to get such answers ! Template loaders is a handy feature, I made my own in minutes. People interested can find it here : http://www.djangosnippets.org/snippets/326/ Cheers, Olivier On 19 juil, 02:03, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/18/07, olivier <[EMAIL PROTECTED]> wrote: > > > I'm thinking about a very simple processor that would remove lines > > beginning by ## (ala mako), because the Django comment syntax is sooo > > verbose and tedious to type > > You'll probably want to implement it as a custom template loader[1]; > Django ships with a couple of different loaders which have different > behaviors for locating templates, but there's no reason why you > couldn't write one which implements whatever preprocessing you want; a > template loader is simply a function which, given a template name and > a list of directories to search, locates and returns the appropriate > contents of a template file to be passed to the Template constructor. > > It'd be fairly easy to write one which, after loading the file, > performs whatever preprocessing you like on the contents before > handing them over (as a string); documentation on how to write > template loaders is a little bit scarce right now, but the bundled > loaders in django.template.loaders[2] provide helpful examples, and > there's also a third-party loader by Jannis Leidel which pulls > templates from a database[3] you might want to look at as an example > of rolling your own. > > [1]http://www.djangoproject.com/documentation/templates_python/#loading-... > [2]http://code.djangoproject.com/browser/django/trunk/django/template/lo... > [3]http://code.google.com/p/django-databasetemplateloader/ > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing FK sets in model methods
You're correct I did have a extra space, but the original problem was syntax error on the following line : if self.segment_set.count() > 0 so my question is : can I acess to FK queryset as described in http://www.djangoproject.com/documentation/db-api/#Backward in a model method thanks On 18 יולי, 17:32, Tim Chase <[EMAIL PROTECTED]> wrote: > > Can someone point me to the problem? > > > class Base(models.Model): > > User = models.CharField(maxlength=200) > > Notes = models.CharField(maxlength=200) # free text > > > def _first_date(self): > >""" Return the first date """ > > if self.segment_set.count() > 0 > > return(self.segment_set.order_by('create_date') > > [0].create_date) > > first_date = property(_first_date) > > > class Segment(models.Model): > > base = models.ForeignKey(Base) > > create_date = models.DateTimeField(auto_now_add=True) > > update_date = models.DateTimeField(auto_now=True) > > Notes = models.CharField(maxlength=200) # free tex > > > # > > D:\Sites\mysite>python manage.py syncdb > > Error: Couldn't install apps, because there were errors in one or more > > models: > > mysite.traveler: invalid syntax (models.py, line 8) > > If you did a copy&paste of your actual code, line #8 ("def > _first_date(self):") seems to have an extra space worth of > indentation from the User/Notes lines. > > Python would flag this as bogus, which in turn would likely > trigger an error in validation. > > -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How do I know if fastcgi is installed correctly? (using dreamhost)
I am trying to follow jeff croft's tutorial for installing django on dreamhost. http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/ I am trying to "Install and configure FastCGI" I followed the tutorial, I don't see where I did anything wrong. One part that I don't quite understand: --- Set up mod_rewrite Apache's mod_rewrite module will pass all requests to your website through dispatch.fcgi, and thus, into Django's URL dispatcher. How I am I supposed to do that? Is that done when I do the pkill python? After the pkill python, the tutorial states: --- All URLs on our subdomain should now be routed to Django. Feel free to open up your browser and try it out for yourself. --- So, I don't have to restart python? Also, what am I supposed to see, if the setup was successful? I gave it a try and the server timed out. Any idea what I did wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: error accessing /admin/doc/views/
On 7/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I can access other pages in the doc area (ex: /admin/doc/filters/ or / > admin/doc/tags/) but when I try to access the views documentation, I > receive: ...snip... > SyntaxError at /admin/doc/views/ > invalid syntax (views.py, line 39) > """ Your best bet is to check your views to ensure that there are no Python syntax errors, and your URLConf to ensure nothing's wrong in there; if an error in one of those files causes problems building the map of URLs to views or importing the views to get their documentation, you'll see these sorts of errors. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQL Clustering
On 7/18/07, Richard Leland <[EMAIL PROTECTED]> wrote: > Trying to set up a connection from Django to a MySQL cluster. I've never > done this before, so any guidance you could provide would be excellent. Though I may be wrong, I was under the impression that the engine only needs to be specified when creating the tables, so probably you'll want to avoid using syncdb -- instead, pipe the output of 'manage.py sql' for each of your apps into a file, add the requisite engine declarations, and run that manually on the SQL node of the cluster. After that, you should be able to have Django connect to the SQL node just as it would connect to any other MySQL database, and (hopefully) things will just work. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
On 7/18/07, Tim Chase <[EMAIL PROTECTED]> wrote: > I dislike CSV because it takes extra overhead to > synchronize the flavors of them (how are quotes quoted? are > values quoted? etc). Psst! Check out Python's built-in ``csv`` module (http://docs.python.org/lib/module-csv.html); it handles all that nastiness for you. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: template preprocessor ?
On 7/18/07, olivier <[EMAIL PROTECTED]> wrote: > I'm thinking about a very simple processor that would remove lines > beginning by ## (ala mako), because the Django comment syntax is sooo > verbose and tedious to type You'll probably want to implement it as a custom template loader[1]; Django ships with a couple of different loaders which have different behaviors for locating templates, but there's no reason why you couldn't write one which implements whatever preprocessing you want; a template loader is simply a function which, given a template name and a list of directories to search, locates and returns the appropriate contents of a template file to be passed to the Template constructor. It'd be fairly easy to write one which, after loading the file, performs whatever preprocessing you like on the contents before handing them over (as a string); documentation on how to write template loaders is a little bit scarce right now, but the bundled loaders in django.template.loaders[2] provide helpful examples, and there's also a third-party loader by Jannis Leidel which pulls templates from a database[3] you might want to look at as an example of rolling your own. [1] http://www.djangoproject.com/documentation/templates_python/#loading-templates [2] http://code.djangoproject.com/browser/django/trunk/django/template/loaders [3] http://code.google.com/p/django-databasetemplateloader/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: model and cascading
On 7/18/07, tyman26 <[EMAIL PROTECTED]> wrote: > Is it possible to set a property in my model that will set update > cascade/delete to true when the tables are generated? I know models > automatically do this anyways when you delete or update, but if I am > working directly with database information it doesn't work > consistently. I know it's possible to simply alter the table within > my database, but if I rebuild the tables with django then I have to > redo this every time. Is this my only solution? Yes. Due to inconsistencies in how different databases handle this functionality (and, in some cases, whether they offer it at all), Django isn't currently able to let you specify a behavior for ON UPDATE/ON DELETE. If you're interested in helping to smooth it out, some of the issues are discussed here: http://groups.google.com/group/django-developers/msg/4c65ac76d85c5c34 -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem when inserting into a table with a MySQL auto_increment primary key
AnaReis skrev: > Hi all, > I have a problem when inserting a register into this table that I'm > working with. > This table belongs to a MySQL database and the storage engine is > MyISAM. The database that I'm using is a legacy database and I can't > change it in any way. > When I insert a register into the table it's MySQL who generates the > primary key for me. Which means that I fill all the required table > fields and leave the primary key field empty for MySQL to fill when I > insert the record. The problem is, since the ".save()" method doesn't > return any value there is no way for me to give any confirmation for > the user if the register was inserted or not. Have you added the primary key to the model, like this: my_legacy_id = AutoField() If you do, I believe you will be able to read the value of the field after calling .save(). At least you can with the standard id field when using postgresql. Nis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
> What about CSV? You can export from Excel as CSV pretty easily and it's a > fairly easy format to parse in python... Either that or tab-delimited text. I have a django app that does bulk data upload from the admin interface according to the following protocol. 1. Users make their bulk upload data tables in excel. 2. They log onto the Django admin site, where I have a special ExcelImport model set up --- it just has a TextField where the data goes. 3. They copy the entire table from excel and paste it in the TextField, then click Save. 4. I have a custom save() method for the ExcelImport class that processes the data and creates the related objects. > > Thanks, > > Dave > > -- > David Reynolds > [EMAIL PROTECTED] > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Picture in admin
Hi Naco On 7/18/07, Naco <[EMAIL PROTECTED]> wrote: > > Does anybody know how to display thumnails in the admin interface? Maybe this is what you want: http://www.djangosnippets.org/snippets/239/ Greetings Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sessions - cookies in opera
Daniel Kontsek skrev: > Hello > > I have a web application with 2 views. The first view checks if the > session dictionary has a 'uid' key - if not it generates an random ID > and puts it into request.session dict. The second view reads the uid > from the session dict and creates a Project DB object with that uid. > This works fine in all browsers (FF, Safari, IE), except Opera. Looks > like Opera (Mac, 9.21.3678) doesn't accept the cookie with the session > info. although cookies are on. Any idea why? > Several possibilities come to mind: - The cookies may be somehow violating the standard. Other browsers may be more accepting of invalid data. - When receiving a cookie received as part of a redirect, it may not be immediately sent with the new request. It is not clear whether this is allowed by the standard - which talks about cookies which the client has "stored". Opera might not have stored the cookie at that point in time. . Opera may be configured to not accept cookies, or be very strict in what it accepts. - Opera may be caching the page that is supposed to set the cookie. This would probably not be happening consistently, though. I think it would be a good idea to look at what actually goes on in the HTTP communication - perhaps logging the two HttpRequests and corresponding HttpResponses /Nis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
We don't need such an app (well, I don't need it). If I want it, I write it in 20 minutes. :-) Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Menu implementation
Lic. José M. Rodriguez Bacallao wrote: > Have anybody implemented a tree with django, for example, a menu? > tree = ui or data structurer? (guessing the answer is yes to both) Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
model and cascading
Is it possible to set a property in my model that will set update cascade/delete to true when the tables are generated? I know models automatically do this anyways when you delete or update, but if I am working directly with database information it doesn't work consistently. I know it's possible to simply alter the table within my database, but if I rebuild the tables with django then I have to redo this every time. Is this my only solution? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
www.cerocom.com
.. www.cerocom.com .. You will be able to ask yourself: Is Internet a good investment for my company? So that an investment would have to do I of this type? Really is going to serve to me to have a Web site? So that to be in Internet? See some of the main advantages have a Web site: · Increase the productivity and to generate more businesses with the implementation of collaboration rofe and integration maximizing the value of Internet and networks IP. · Offer solutions of Internet, integration and collaboration in accordance with our clients, anyone is their size or trains, to rofesional r to integrate their applications, to fortify their present position in the market or to impel their growth, assuring trustworthiness, discharge rofesional qualification, and customized service. I invite it to cross the Web site and interiorice of the services available. www.cerocom.com Contact: Commercial direction: Viamonte 783 Piso 3° Capital Federal (C1053ABO) Bs. As. Argentina Tel/Fax: (54.11) 4322.1201 Celular: (54-9-11) (15) 5006.4384 Mail: [EMAIL PROTECTED] Web Site: www.cerocom.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Picture in admin
Here's something on djangosnippets.org for displaying thumbnails in the admin list: http://www.djangosnippets.org/snippets/239/ Or do you mean on the page for editing a record? Nathan Ostgard On Jul 18, 2:11 pm, Naco <[EMAIL PROTECTED]> wrote: > Does anybody know how to display thumnails in the admin interface? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
MySQL Clustering
Trying to set up a connection from Django to a MySQL cluster. I've never done this before, so any guidance you could provide would be excellent. I know that DATABASE_OPTIONS can be used in the settings.py file, just not sure if that's the right course of action or even how to write this into the DATABASE_OPTIONS dict. I know that any query on the DB needs to specify the engine as NDBCLUSTER like so: mysql> CREATE TABLE x ( -> id int(11) NOT NULL AUTO_INCREMENT, -> c char(10) DEFAULT NULL, -> PRIMARY KEY (id) -> ) ENGINE=NDBCLUSTER DEFAULT CHARSET=utf8; thanks in advance! Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Slug (w/o using SlugField) Problems
On Wed, Jul 18, 2007 at 07:10:27PM -, John-Scott wrote: > Next, change your urls.py like so: > > (r'^characters/(?P\d+)[-\w]+/$', object_detail, > dict(character_detail_dict)), > > This should capture the '123' and discard '-bob-and-jane'. This is a > fairly elegant solution that allows you to still have 'pretty' urls > that are human readable and google friendly while completely > sidestepping the complications of record retrieval based on reverse > engineering slugs or bothering with a slug column, opting instead for > the dead-simple and fast id lookup. Don't we all agree that unique URLs with one-to-one relationships with unique resources are a Good Thing? I sure thought we did... Multiple URLs corresponding to the same resource will actually dilute your Google rank, anyway (if someone out in space uses the non-canonical version in a link). You could do a permanent redirect to the canonical version, I guess. -Forest signature.asc Description: Digital signature
Re: Slug (w/o using SlugField) Problems
The option I want to implement, and which my be a suitable solution for your situation, is to combine the object id with the slugified version of the object name. Then in your urls.py, only capture the object id and ignore the slug when retrieving the object (this gets you past any issues with reversibility). So you'd end up with something like: def get_absolute_url(self): return "/characters/%s/" % self.id + '-' + (slugify(self.name)) ...in your model, resulting in a url like "/characters/123-bob-and- jane". Your urls.py would need something like: (r'^characters/(?P\d+)[-\w]+/$', object_detail, ... This should capture the '123' of the slug and ignore the '-bob-and- jane'. So you only use the slug for pretty urls aka human readable and search engine friendly urls but still rely on the id value for quick and painless database lookups. My question is did you write your own 'slugify' method or is this included in core somewhere and I just need the appropriate import statement in my model files? Cheers, John-Scott On Jul 6, 4:27 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > >> You might need to adopt a different approach to URL construction that is > >> reversible (writing your own version of slugify, possibly?). > > > Thanks for the help Malcolm. Using Jeff Croft's "I'm not a programmer" > > excuse, would it be too much trouble to request a small example of a > > reversible slugify? > > Given that any general "slugify" method throws away information > (case, spaces, punctuation, etc), there's no way to fabricate > that information for reversal short of keeping the original and > working backwards. > > However, you can use the urllib.quote() and urllib.unquote() > functions instead, which may do the trick. > > You may have to modify the regexp in your urls.py to handle > standard quoted characters rather than just "slug" chars. > > -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
error accessing /admin/doc/views/
I can access other pages in the doc area (ex: /admin/doc/filters/ or / admin/doc/tags/) but when I try to access the views documentation, I receive: """ SyntaxError at /admin/doc/views/ invalid syntax (views.py, line 39) Request Method: GET Request URL:http://localhost:8000/admin/doc/views/ Exception Type: SyntaxError Exception Value:invalid syntax (views.py, line 39) Exception Location: C:\Python25\lib\site-packages\django\core \urlresolvers.py in _get_callback, line 125 Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25\lib\site-packages\django\contrib\admin\views \decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py" in view_index 108. view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns) File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py" in extract_views_from_urlpatterns 341. views.extend(extract_views_from_urlpatterns(patterns, base + p.regex.pattern)) File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py" in extract_views_from_urlpatterns 333. views.append((p._get_callback(), base + p.regex.pattern)) File "C:\Python25\lib\site-packages\django\core\urlresolvers.py" in _get_callback 125. self._callback = getattr(__import__(mod_name, {}, {}, ['']), func_name) SyntaxError at /admin/doc/views/ invalid syntax (views.py, line 39) """ I'm using .96, and Python 2.5 on windoze. I see some posts about not being able to access the views because of a decorator issue, but they don't seem related. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem when inserting into a table with a MySQL auto_increment primary key
If there's a problem, it will raise an exception, so you won't just slide past invisibly. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms and models unique=True validation
You can create a BaseForm class and specify it in your form_for_model call: from django import newforms as forms class MyBaseForm(forms.BaseForm): def clean_myfield(self): if MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count(): raise forms.ValidationError('some error message') MyForm = forms.form_for_model(MyModel, form=MyBaseForm) Nathan Ostgard On Jul 18, 7:06 am, stereoit <[EMAIL PROTECTED]> wrote: > Hi, > I have model with field that has attribute unique set to True. I know > newforms are not able to handle such a validation as this is DB > related. However I read at newforms doc page that it is possible to > provide method called clean_() that can do custom validation. > My problem is that method is supposed to access the data via > self.cleaned_date and I create form by using form_for_model hence I do > not know how to write such a method. > > Can anyone point me to right direction or best practice? Handling this > at form.save() seem not right to me. > > My idea was to create custom validation method that would try tu pull > object from DB with set to same as in > cleaned_data['fieldname'] and if it exists it would raise > ValidationError. But I have no clue how to do that at the moment. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Picture in admin
Does anybody know how to display thumnails in the admin interface? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms and models unique=True validation
You want to create a BaseForm to specify in your form_for_model call. You could do something like: from django import newforms as forms class MyBaseForm(forms.BaseForm): def clean_myfield(self): if MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count(): raise forms.ValidationError('some error message') MyForm = forms.form_for_model(MyModel, form=MyBaseForm) Nathan Ostgard On Jul 18, 7:06 am, stereoit <[EMAIL PROTECTED]> wrote: > Hi, > I have model with field that has attribute unique set to True. I know > newforms are not able to handle such a validation as this is DB > related. However I read at newforms doc page that it is possible to > provide method called clean_() that can do custom validation. > My problem is that method is supposed to access the data via > self.cleaned_date and I create form by using form_for_model hence I do > not know how to write such a method. > > Can anyone point me to right direction or best practice? Handling this > at form.save() seem not right to me. > > My idea was to create custom validation method that would try tu pull > object from DB with set to same as in > cleaned_data['fieldname'] and if it exists it would raise > ValidationError. But I have no clue how to do that at the moment. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
template preprocessor ?
Hi group, Is there an easy way to plug a preprocessor to the templating system ? I'm thinking about a very simple processor that would remove lines beginning by ## (ala mako), because the Django comment syntax is sooo verbose and tedious to type Cheers, Olivier --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Slug (w/o using SlugField) Problems
Hello, I'm using a solution I saw on a RoR blog (http:// blog.hasmanythrough.com/2006/7/7/more-on-naming-and-the-crud has a summary of the technique) which should address the 'reversibility' issue. Basically you just concatenate the object id with the slug of the human readable name, but then just ignore everything but the object id in your urlpatterns. First, you'd change your model like so: def get_absolute_url(self): return "/characters/%s/" % self.id + '-' + (slugify(self.name)) This will generate urls like "/characters/123-bob-and-jane". Next, change your urls.py like so: (r'^characters/(?P\d+)[-\w]+/$', object_detail, dict(character_detail_dict)), This should capture the '123' and discard '-bob-and-jane'. This is a fairly elegant solution that allows you to still have 'pretty' urls that are human readable and google friendly while completely sidestepping the complications of record retrieval based on reverse engineering slugs or bothering with a slug column, opting instead for the dead-simple and fast id lookup. Hope this helps. Btw, I assume you're just importing the slugify method from django.template.defaultfilters? This is what I did, rather than write my own method. Cheers, John-Scott (note: I tried writing this response a few hours ago, but it doesn't appear to have posted correctly. If it magically appears, I'll remove the duplicate post) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
> left: bulk upload. I've thought of using xls (microsoft > office's excel files) to make it easy on the client, because > teaching them xml or yaml isn't the big deal. After thinking > about it, finding a xls parser module for python might not be > the problem, I second the idea of using a plain-text interchange format, whether CSV as David suggested, or (my preferred) tab-delimited format. I dislike CSV because it takes extra overhead to synchronize the flavors of them (how are quotes quoted? are values quoted? etc). I find TAB format just less messy. > but how could I take on product images? How can I > bulk upload those? Ok, I can upload a tar or zip file and have > it unpacked automatically, but how do I automagically assign > the images with the product, having in mind that some might > have 5 pics and others might have 2 or none. Your idea of uploading a zip/tar archive is a good one. One would need to go with naming conventions. Images could be named of the format _.[jpg|gif] and then any corresponding items could be added to your ProductImages table. This assumes you have a column in your upload file. You might want to report on items in the image-archive that don't have a corresponding item in the upload file (or aren't already in the data...might be easier). To augment Adam's suggestion, a lot of the code can be made shorter and more readable using Python's tuple-assignment, so rather than having hard-coded indicies such as "product.slug = raw_data[6]", you can do something like (in_id, manufacturer, vendor, dealer_price, dealer_price_updated, model, slug, description, package_contents, ... ) = raw_data You can then use each of these parts for later assignment, or even directly assign them like (in_id, manufacturer, ... product.model, product.slug, product.description, ... ) = raw_data This does assume a fixed column order, which would require some tweaks if the columns could be in an arbitrary order. However, a little dictionary trickery can solve that. I usually do this via REQUIRED_COLUMNS = [ 'manufacturer', 'slug', ... ] for row_num, row in file(filename): row = row.rstrip('\n').split(DELIM) if row_num == 0: header_to_column = dict([ (n, i) for (i,n) in enumerate(row)]) header_set = set([h.lower() for h in row]) for header in REQUIRED_COLUMNS: assert header in header_set, 'Missing column %s' % header continue # use header_to_column to map the desired column name # to its offset/index -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Menu implementation
On 7/18/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > Have anybody implemented a tree with django, for example, a menu? > > -- > Lic. José M. Rodriguez Bacallao > Cupet I've implemented a tree of comments in django-discussion: http://django-discussion.googlecode.com/svn/trunk/models.py It shouldn't be too hard to modify that for your own ends if it's suitable - it uses Modified Preorder Tree Traversal as described here: http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal I've also *just about* finished my first hackety stab at a (non database-backed) Section/Page menu system (where each section may contain a number of pages) which takes into account which users should be able to see which links - I'll probably put it on Django Snippets once it's "working". I'd ideally like to go on to extract a generic implementation of this functionality, but time is in short supply as always! :) Regards, Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Unique=true
Nis Jørgensen skrev: > [EMAIL PROTECTED] skrev: > >> OK, fixed the above problem -- figured out that it was related to my >> setting unique=True on a field. But that raises the larger question... >> >> I have a bit of data that may or may not exist... a identifier on the >> user that not all users will have, but if they DO have it, it needs to >> be unique to that user. Apparently, unique=True isn't what I want, >> because the second user without it throws the above duplicate entry >> error, so how do I handle that? >> >> > I believe the behavior depends on your database backend. Postgresql does > what you want. > > Postgresql is, AFAICT, complying with at least one of the SQL standards > (but I don't have a copy of those) > It seems mysql 5 works the same way as postgres - and it seems the error message you quoted was from postgres. It seems to me you do not have null=True set for the Field. Thus blank values are stored as empty strings, which unlike NULLS are equal to each other. /Nis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing FK sets in model methods
> Can someone point me to the problem? > > class Base(models.Model): > User = models.CharField(maxlength=200) > Notes = models.CharField(maxlength=200) # free text > > def _first_date(self): >""" Return the first date """ > if self.segment_set.count() > 0 > return(self.segment_set.order_by('create_date') > [0].create_date) > first_date = property(_first_date) > > class Segment(models.Model): > base = models.ForeignKey(Base) > create_date = models.DateTimeField(auto_now_add=True) > update_date = models.DateTimeField(auto_now=True) > Notes = models.CharField(maxlength=200) # free tex > > # > D:\Sites\mysite>python manage.py syncdb > Error: Couldn't install apps, because there were errors in one or more > models: > mysite.traveler: invalid syntax (models.py, line 8) If you did a copy&paste of your actual code, line #8 ("def _first_date(self):") seems to have an extra space worth of indentation from the User/Notes lines. Python would flag this as bogus, which in turn would likely trigger an error in validation. -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
I won't attempt to tackle the image conundrum (because our old ecommerce site is of the single-image variety, which makes it easy). The other, though I can help you with. My models yield four tables (products, product_categories, product_site to tie it to a site, and product_attributes). I wrote in C# an exporter application from our old system (.NET) and made it output pipe-delimited files in the format of my models in django, whether that data was stored previously or not, just to keep it clean and readable. The C# app takes some information such as what ID the next imported product will start with, and uses it to build rows and save them. This may help, it may not...but below is my importprocess.pythat handles all of this, at least on the django side. It's not a perfect implementation, because it was only used once - to move data over. It runs in the shell, but it could be wrapped in a view as well. I've changed a few names and such to protect who we are...we are not yet switched over to the django site, several other projects have come up for me to work on. I will most certainly announce though once we do go live. *importprocess.py from project.products.models import Product, Manufacturer, Warranty, Category, ProductAttribute, ProductAttributeChoice from django.contrib.sites.models import Site def import_products(): filename = "c:/import/products.txt" file = open(filename) while 1: lines = file.readlines(10) if not lines: break for line in lines: raw_data = line.split('|') product = Product() #raw_data[0] #id left alone, db will handle #raw_data[1] #manufacturer prd_man_list = Manufacturer.objects.filter (id__exact=raw_data[1]) if prd_man_list: prd_man = prd_man_list[0] product.manufacturer = prd_man #raw_data[2] #vendor #not implemented previously, left out #raw_data[3] #dealer_price #not implemented previously, left out #raw_data[4] #dealer_price_updated #not implemented previously, left out #raw_data[5] #model product.model = raw_data[5] #raw_data[6] #slug product.slug = raw_data[6] #raw_data[7] #description product.description = raw_data[7] #raw_data[8] #package_contents #not implemented previously, left out #raw_data[9] #warranty if raw_data[9] != '': if int(raw_data[9]) > 0: warranty_list = Warranty.objects.filter (id__exact=raw_data[9]) if warranty_list: warranty = warranty_list[0] product.warranty = warranty else: warranty_list = Warranty.objects.filter(id__exact=15) if warranty_list: warranty = warranty_list[0] product.warranty = warranty else: warranty_list = Warranty.objects.filter(id__exact=15) if warranty_list: warranty = warranty_list[0] product.warranty = warranty #raw_data[10] #MAP product.map = raw_data[10] #raw_data[11] #on_site_price #not implemented previously, left out #raw_data[12] #in_cart_price product.in_cart_price = raw_data[12] #raw_data[13] #released #not implemented previously, left out #raw_data[14] #discontinued #not implemented previously, left out #raw_data[15] #length #not implemented previously, left out #raw_data[16] #width #not implemented previously, left out #raw_data[17] #height #not implemented previously, left out #raw_data[18] #weight product.weight = raw_data[18] #raw_data[19] #shipping_weight product.shipping_weight = raw_data[19] #raw_data[20] #shipping_length product.shipping_length = raw_data[20] #raw_data[21] #shipping_width product.shipping_width = raw_data[21] #raw_data[22] #shipping_height product.shipping_height = raw_data[22] #raw_data[23] #shipping_flat_cost #not implemented previously, left out #raw_data[24] #show_in_stock product.show_in_stock = raw_data[24] #raw_data[25] #spec_pdf product.spec_pdf = raw_data[25] #raw_data[26] #highlight_large product.highlight_large = raw_data[26] #raw_data[27] #highlight_medium product.highlight_medium = raw_data[27] #raw_data[28] #highlight_thumbnail product.highlight_thumbnail = raw_da
Menu implementation
Have anybody implemented a tree with django, for example, a menu? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Accessing FK sets in model methods
Hi, My name is Ilan, and I kind of new working with Django. I have a question about model methods. I trying to write a model method which access ForeignKey FOO_set functionality Whoever it does not seems to pass the "syncdb" validation, because of invalid syntax Can someone point me to the problem? # from django.db import models from django.contrib.auth.models import User class Base(models.Model): User = models.CharField(maxlength=200) Notes = models.CharField(maxlength=200) # free text def _first_date(self): """ Return the first date """ if self.segment_set.count() > 0 return(self.segment_set.order_by('create_date') [0].create_date) first_date = property(_first_date) class Segment(models.Model): base = models.ForeignKey(Base) create_date = models.DateTimeField(auto_now_add=True) update_date = models.DateTimeField(auto_now=True) Notes = models.CharField(maxlength=200) # free tex # D:\Sites\mysite>python manage.py syncdb Error: Couldn't install apps, because there were errors in one or more models: mysite.traveler: invalid syntax (models.py, line 8) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
custom order_by?
Folks, In spirit of recent question regarding custom 'where'... Is there a way to put a custom ORDER BY into QuerySet? I have an sql function that does all the math on db side and would like to use it at order_by clause I quickly skimmed _get_sql_clause and haven't found any way to incorporate something like "ORDER BY calc_post_rating(id)". Am I wrong or is the only way to have this to override/hack _QuerySet._get_sql_clause? TIA! -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua OR skype://akhavr --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms and models unique=True validation
Hi, I have model with field that has attribute unique set to True. I know newforms are not able to handle such a validation as this is DB related. However I read at newforms doc page that it is possible to provide method called clean_() that can do custom validation. My problem is that method is supposed to access the data via self.cleaned_date and I create form by using form_for_model hence I do not know how to write such a method. Can anyone point me to right direction or best practice? Handling this at form.save() seem not right to me. My idea was to create custom validation method that would try tu pull object from DB with set to same as in cleaned_data['fieldname'] and if it exists it would raise ValidationError. But I have no clue how to do that at the moment. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Bulk data upload
On 18 Jul 2007, at 12:00 pm, Chris Hoeppner wrote: Hi there! I've been working on an ecommerce solution. So far everything works like it should. There's just one "nice to have" feature left: bulk upload. I've thought of using xls (microsoft office's excel files) to make it easy on the client, because teaching them xml or yaml isn't the big deal. After thinking about it, finding a xls parser module for python might not be the problem, but how could I take on product images? How can I bulk upload those? Ok, I can upload a tar or zip file and have it unpacked automatically, but how do I automagically assign the images with the product, having in mind that some might have 5 pics and others might have 2 or none. What about CSV? You can export from Excel as CSV pretty easily and it's a fairly easy format to parse in python... Thanks, Dave -- David Reynolds [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
Re: Django's User authentication
james_027 <[EMAIL PROTECTED]> writes: > what if I need additional fields or methods for my apps? Do i inherit > it or edit the user class? The standard approach is here: http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model However, also have a look at this approach: http://groups.google.com/group/django-developers/browse_thread/thread/f62b05cae5e5f462/55889eafe381a09b?lnk=gst&q=multiple+profiles&rnum=1#55889eafe381a09b It does require writing a context processor and a middleware, but they are very small and simple, and they greatly simplify the use of your user object in your views and templates. -- +---+ | Jason F. McBrayer[EMAIL PROTECTED] | | If someone conquers a thousand times a thousand others in | | battle, and someone else conquers himself, the latter one | | is the greatest of all conquerors. --- The Dhammapada| --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: DMigrate - A Django Database Migration Tool
On 7/18/07, Ben Ford <[EMAIL PROTECTED]> wrote: > Just out of interest have you explored using SQLAlchemy directly with the > django model..? I mean mapping the SA Table onto the django Model..? I had a > play with that a while back and it seems a very straightforward way of > achieving SA - django integration... > Ben > No, I haven't tried it. In the script DMigrate creates, there are SA classes which interact with the source database, and Django classes which interact with the destination database. They don't touch one another. Noam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Special Django Presentation at PyAtl
Just an FYI, For all of you folks in the Atlanta Area, we have a special Django Presentation on Aug. 9th at Turner Studios by a leading Django instructor from the Big Nerd Ranch. Please see our meetup event for more details: http://python.meetup.com/46/calendar/5900658/ Thanks, Noah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Special Django Presentation at PyAtl
Just an FYI, For all of you folks in the Atlanta Area, we have a special Django Presentation on Aug. 9th at Turner Studios by a leading Django instructor from the Big Nerd Ranch. Please see our meetup event for more details: http://python.meetup.com/46/calendar/5900658/ Thanks, Noah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: DMigrate - A Django Database Migration Tool
Just out of interest have you explored using SQLAlchemy directly with the django model..? I mean mapping the SA Table onto the django Model..? I had a play with that a while back and it seems a very straightforward way of achieving SA - django integration... Ben On 18/07/07, Noam <[EMAIL PROTECTED]> wrote: > > > On Jul 18, 4:47 am, "Ben Ford" <[EMAIL PROTECTED]> wrote: > > > I haven't looked at the code, but I wonder about the dependency on > > > multiple ORMs; the Django ORM cannot expose its own functionality on > > > multiple databases at once... > > > > It can using the multiple-db-support branch (see ticket 4747 for a patch > > bringing the branch up to date)... > > If it's merged into the trunk, there indeed will be no need to use > SQLAlchemy. It will be very nice! > > > There's also a similar module (on > > djangosnippets I think) which enables extraction/insertion of a database > > into/from a list of python files. It's pretty good!! > > Thanks for the reference! You probably mean > http://www.djangosnippets.org/snippets/167/ > . It's very nice. I still prefer my method, but I would like to hear > what others think about it. > > (Ok, I'll say why I prefer my method. Pickle is complicated. You never > know exactly what's in that pickle file. On the other hand, a script > which copies data from one database into another is easy to understand > and modify. It also doesn't require you to write plugins to modify > classes - you just modify the script in a straightforward way. And > still, I'm biased. I would like to hear what others think.) > > Noam > > > > > -- Regards, Ben Ford [EMAIL PROTECTED] +628111880346 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
edit_inline for a reflexive m2m_intermediary
I'm following the m2m_intermediary pattern: 9. Many-to-many relationships via an intermediary table http://www.djangoproject.com/documentation/models/m2m_intermediary/ However, I need associations, not between two different models, but between pairs of instances of the *same* model, as discussed in this thread: Friendship_type on symmetrical M2M http://groups.google.com/group/django-users/browse_thread/thread/72afc8b5540dd75e/68688173a04a027d Take this Person model: class Person(models.Model): first_name = models.CharField(maxlength = 100) last_name = models.CharField(maxlength = 100) and associate pairs of persons, while adding some data: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of') associate = models.ForeignKey(Person, related_name='friends') some_data = models.IntegerField() The admin interface for these models works correctly. Now, to be able to add Associations while editing Persons, I add edit_inline and core to Association fields. If I add them to both ForeignKey fields: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of', core=True, edit_inline=models.TABULAR) associate = models.ForeignKey(Person, related_name='friends', core=True, edit_inline=models.TABULAR) dummy = models.IntegerField() I get this error: Traceback (most recent call last): File ".../django/template/__init__.py" in render_node 754. result = node.render(context) File ".../django/template/defaulttags.py" in render 134. nodelist.append(node.render(context)) File ".../django/contrib/admin/templatetags/admin_modify.py" in render 171. bound_related_object = relation.bind( context['form'], original, bound_related_object_class) File ".../django/db/models/related.py" in bind 129. return bound_related_object_class(self, field_mapping, original) File ".../django/contrib/admin/templatetags/admin_modify.py" in __init__ 138. for (i,field_mapping) in self.field_mappings.items() ] File ".../django/oldforms/__init__.py" in items 264. self.fill() File ".../django/oldforms/__init__.py" in fill 283. field = self.parent_manipulator[full_field_name] File ".../django/oldforms/__init__.py" in __getitem__ 28. raise KeyError, "Field %s not found\n%s" % ( field_name, repr(self.fields)) KeyError at /admin/person/add/ 'Field association.0.associate not found [FormField "first_name", FormField "last_name", FormField "association.0.id", FormField "association.0.person", FormField "association.0.dummy", FormField "association.1.id", FormField "association.1.person", FormField "association.1.dummy", FormField "association.2.id", FormField "association.2.person", FormField "association.2.dummy", FormField "association.0.id", FormField "association.0.person", FormField "association.0.dummy", FormField "association.1.id", FormField "association.1.person", FormField "association.1.dummy", FormField "association.2.id", FormField "association.2.person", FormField "association.2.dummy"]' If I only add edit_inline and core to the first ForeignKey field: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of', core=True, edit_inline=models.TABULAR) associate = models.ForeignKey(Person, related_name='friends') dummy = models.IntegerField() I get this other error: Traceback (most recent call last): File ".../django/template/__init__.py" in render_node 754. result = node.render(context) File ".../django/template/defaulttags.py" in render 134. nodelist.append(node.render(context)) File ".../django/contrib/admin/templatetags/admin_modify.py" in render 171. bound_related_object = relation.bind( context['form'], original, bound_related_object_class) File ".../django/db/models/related.py" in bind 129. return bound_related_object_class(self, field_mapping, original) TypeError at /admin/diet/person/add/ 'bool' object is not callable What am I missing? -- Nicola Larosa - http://www.tekNico.net/ The smart way to keep people passive and obedient is to strictly limit the spectrum of acceptable opinion, but allow very lively debate within that spectrum. -- Noam Chomsky, quoted by David Icke, February 2007 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django's User authentication
what if I need additional fields or methods for my apps? Do i inherit it or edit the user class? Thanks james On Jul 18, 3:45 pm, Przemek Gawronski <[EMAIL PROTECTED]> wrote: > > is this use for the django admin features only? or I can use it for my > > own app? if yes, do I make it suitable for my application? > > Sure you can, tak a look at: > > http://www.djangoproject.com/documentation/authentication/#how-to-log... > > Przemek > -- > AIKIDO TANREN DOJO - Poland - Warsaw - Mokotow - Ursynow - Natolin > info:http://www.tanren.pl/phone: +4850151 email: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Bulk data upload
Hi there! I've been working on an ecommerce solution. So far everything works like it should. There's just one "nice to have" feature left: bulk upload. I've thought of using xls (microsoft office's excel files) to make it easy on the client, because teaching them xml or yaml isn't the big deal. After thinking about it, finding a xls parser module for python might not be the problem, but how could I take on product images? How can I bulk upload those? Ok, I can upload a tar or zip file and have it unpacked automatically, but how do I automagically assign the images with the product, having in mind that some might have 5 pics and others might have 2 or none. Any ideas? signature.asc Description: OpenPGP digital signature
Re: Logging in a newly created user
On Jul 18, 9:08 am, Jonathan Buchanan <[EMAIL PROTECTED]> wrote: > LaundroMat wrote: > > Hi, > > > When running this, I get a "NoneType has no attribute > > is_authenticated()" error, and I cannot understand why: > > > 1 new_user = User.objects.create_user(username, "your.email", > > password) > > 2 new_user.is_active = False > > 3 new_user.save() > > 4 user = authenticate(username = new_user.username, password = > > new_user.password) # Seehttp://code.djangoproject.org/ticket/2656 > > 5 if user.is_authenticated(): # The error is produced here. > > login(request, user) > > > Why does authenticate() in line 4 return a None object instead of a > > user? > > > Thanks for your help, > > > Mathieu > > "If the password is invalid, authenticate() returns None" [1] > > The password field in the User model contains "...a hash of, and > metadata about, the password. (Django doesn't store the raw password.)" [2] > > So authenticate is returning None because you're trying to login with a > hashed version of the password, not the raw version. Try this instead: > > user = authenticate(username=username, password=password) > > Look at the second code example under [1] for an example of how to do this. > > Jonathan. > > [1]http://www.djangoproject.com/documentation/authentication/#how-to-log... > > [2]http://www.djangoproject.com/documentation/authentication/#fields Thanks! I should have come up with this myself, but I guess the coffee hadn't kicked in yet. Many thanks for the quick and informative reply. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inheriting models' fields, methods and managers
On Wed, 2007-07-18 at 09:48 +, omat wrote: > Hi all, > > Recently, it occurred to me that, defining some abstract models for > some types of applications would make my code significantly DRYer, by > eliminating duplication of common fields, model methods and manager > methods. > > Examples of common groups of applications are: > > - Orthogonal applications, that is, applications that hold content > related to other applications, such as tags. > - Hierarchically categorized content > - User contributed content > > There had been some discussion on "model inheritance" on the > developers' list about a year ago, but this is basically for content > that is hierarchically related, such as "carnivores are subclass of > animals" and would be defined as: > > class Carnivore(Animal) > > But what I want is a bit different (and simpler). For example, for > hierarchical content, define a Node() base model class as follows: > > class Node(models.Model): > parent = models.ForeignKey('self') > objects = NodeManager() > > And a manager class as follows: > > class NodeManager(models.Manager): > def get_children(self, node): > return self.filter(parent = node) > > def get_neighbours(self, node): > return self.filter(parent = node.parent).exclude(id = node.id) > > Whenever a model holds hierarchical content, subclass Node(), like > that: > > class MenuItem(Node): > title = models.CharField(maxlength=50) > > > I only tested with the Ortho() model class which can be found in the > thread I started yesterday, before the issues appeared to be more > complicated than I thought: > http://groups.google.com/group/django-users/browse_thread/thread/975d56dff34a8784 > > When 'syncdb'ed, it created a single table with the methods and fields > from the base class included. With this approach, base class' fields > and methods can be accessed with dot notation. > > But: > - relations in the base class does not work, i.e. I cannot say "parent > = models.ForeignKey('self')" > - you cannot access the manager, but you can refer to the manager from > within the subclass, so not a big issue > - django goodies such as "get_object_or_404" fail with " Programming > Error: relation "models_[basemodel]" does not exist", i.e. requires to > have the table for the base class. But if you avoid using those > goodies, and go with simple api methods, it works. > - admin application frequently compşains with the same "Programming > Error" > > > Is there a way to achieve that kind of inheritance? You can't do it at the moment, but it's one of the completion requirements for model inheritance. It's exactly the abstract base class scenario: all the parent model fields will be installed in the child as though they were defined there. Parents will (possibly) never exist in isolation. I say "possibly", because it's not clear at the moment if the declaration that the parent class is abstract is a property of the parent (a la C++) or the child. So it's a "coming soon" feature. Regards, Malcolm -- A clear conscience is usually the sign of a bad memory. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
inheriting models' fields, methods and managers
Hi all, Recently, it occurred to me that, defining some abstract models for some types of applications would make my code significantly DRYer, by eliminating duplication of common fields, model methods and manager methods. Examples of common groups of applications are: - Orthogonal applications, that is, applications that hold content related to other applications, such as tags. - Hierarchically categorized content - User contributed content There had been some discussion on "model inheritance" on the developers' list about a year ago, but this is basically for content that is hierarchically related, such as "carnivores are subclass of animals" and would be defined as: class Carnivore(Animal) But what I want is a bit different (and simpler). For example, for hierarchical content, define a Node() base model class as follows: class Node(models.Model): parent = models.ForeignKey('self') objects = NodeManager() And a manager class as follows: class NodeManager(models.Manager): def get_children(self, node): return self.filter(parent = node) def get_neighbours(self, node): return self.filter(parent = node.parent).exclude(id = node.id) Whenever a model holds hierarchical content, subclass Node(), like that: class MenuItem(Node): title = models.CharField(maxlength=50) I only tested with the Ortho() model class which can be found in the thread I started yesterday, before the issues appeared to be more complicated than I thought: http://groups.google.com/group/django-users/browse_thread/thread/975d56dff34a8784 When 'syncdb'ed, it created a single table with the methods and fields from the base class included. With this approach, base class' fields and methods can be accessed with dot notation. But: - relations in the base class does not work, i.e. I cannot say "parent = models.ForeignKey('self')" - you cannot access the manager, but you can refer to the manager from within the subclass, so not a big issue - django goodies such as "get_object_or_404" fail with " Programming Error: relation "models_[basemodel]" does not exist", i.e. requires to have the table for the base class. But if you avoid using those goodies, and go with simple api methods, it works. - admin application frequently compşains with the same "Programming Error" Is there a way to achieve that kind of inheritance? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: DMigrate - A Django Database Migration Tool
On Jul 18, 4:47 am, "Ben Ford" <[EMAIL PROTECTED]> wrote: > > I haven't looked at the code, but I wonder about the dependency on > > multiple ORMs; the Django ORM cannot expose its own functionality on > > multiple databases at once... > > It can using the multiple-db-support branch (see ticket 4747 for a patch > bringing the branch up to date)... If it's merged into the trunk, there indeed will be no need to use SQLAlchemy. It will be very nice! > There's also a similar module (on > djangosnippets I think) which enables extraction/insertion of a database > into/from a list of python files. It's pretty good!! Thanks for the reference! You probably mean http://www.djangosnippets.org/snippets/167/ . It's very nice. I still prefer my method, but I would like to hear what others think about it. (Ok, I'll say why I prefer my method. Pickle is complicated. You never know exactly what's in that pickle file. On the other hand, a script which copies data from one database into another is easy to understand and modify. It also doesn't require you to write plugins to modify classes - you just modify the script in a straightforward way. And still, I'm biased. I would like to hear what others think.) Noam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem when inserting into a table with a MySQL auto_increment primary key
Hi all, I have a problem when inserting a register into this table that I'm working with. This table belongs to a MySQL database and the storage engine is MyISAM. The database that I'm using is a legacy database and I can't change it in any way. When I insert a register into the table it's MySQL who generates the primary key for me. Which means that I fill all the required table fields and leave the primary key field empty for MySQL to fill when I insert the record. The problem is, since the ".save()" method doesn't return any value there is no way for me to give any confirmation for the user if the register was inserted or not. The only way to check if the new record was inserted is to go to the table and check if the register is there or not. Is there any way to go around this? I thought, since this is a MyISAM table, I could get the last inserted record but I still have no guaranty that the last record was the one inserted by the user since there can be two equal lines in the table with the same information but with a different primary key... How do I know if the last record was inserted by the user (which means the insert was successful) or if it was already there before and there was a problem with this last insert? Ana --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: DMigrate - A Django Database Migration Tool
Thanks for your comment! Relying on another ORM isn't technically necessary, but it seems to me the easiest way - instead of issuing select statements, the generated code looks like this: for s in src.myapp.City.select(): d = dst.myapp.City() d.id = s.id d.name = s.name d.save() Using select statements, the code would have been much uglier, and much harder to modify, I think. Noam On Jul 18, 4:36 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/17/07, Noam Raphael <[EMAIL PROTECTED]> wrote: > > > I would really like to hear what you think about it (especially if > > it's good things...) Tell me! > > I haven't looked at the code, but I wonder about the dependency on > multiple ORMs; the Django ORM cannot expose its own functionality on > multiple databases at once, but this does not mean you cannot have > connections open to multiple databases at once -- if you have the > location and credentials for the second connection, you can simply > drop down to the database adapter module, open a new connection > independently of Django and use the standard Python DB API to execute > any SQL you like. > > So unless you're relying heavily on ORM methods to access the data, > instead of using simple SELECT statements, there's not any technical > need to install another ORM package. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MEDIA_URL MEDIA_ROOT problem.
Thanks to all for help. With your suggestions and links I've found out how to serve static files with Django. Now everything works just fine! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
On 18-Jul-07, at 11:31 AM, James Bennett wrote: > So I'm not necessarily convinced that there's a great need for a > "standard" Django blog application; it would appease some folks, but I > have a feeling that in the Django world a lot of people really would > be happier, in the long run, writing their own app that does what they > need except for nesh's thumbnails, i have always found it quicker to roll my own things rather than spend time bolting on someone else's app to my app. -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to select objects referenced by another table ?
On 17 juil, 20:29, Tim Chase <[EMAIL PROTECTED]> wrote: > Fortunately, Django's ORM lets you get at the underlying SQL via > a call to .extra() where you can provide your own WHERE clause. > This would look something like > >Article.objects.extra(where=""" > app_article.id in (select article_id from app_photo) > """) > > You'd have to adjust for the various column-names and table-names > accordingly. Argl, I missed the 'extra' method in the documentation, thanks a lot ! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django's User authentication
> is this use for the django admin features only? or I can use it for my > own app? if yes, do I make it suitable for my application? Sure you can, tak a look at: http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in Przemek -- AIKIDO TANREN DOJO - Poland - Warsaw - Mokotow - Ursynow - Natolin info: http://www.tanren.pl/ phone: +4850151 email: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django's User authentication
hi, is this use for the django admin features only? or I can use it for my own app? if yes, do I make it suitable for my application? Thanks james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: session question
On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote: > > sorry for this stupid question ... does django's session only work > when cookies are enabled? Yes. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: model managers of base classes
Are you working on a specific application that uses model inheritance, or testing the models I posted in the first message in this thread? Also, previously, you've mentioned something that you will post to another list. I didn't get that either. I was using the model api. The error is: Programming Error: relation "models_ortho" does not exist Naturally, if you access a view function that has this error via http, you will see Http500. Thanks, oMat On 17 Temmuz, 19:58, Carl Karsten <[EMAIL PROTECTED]> wrote: > Thanks - I think I bumped into that yesterday and got distracted trying to > setup > a test on a win box (yay) > > I was getting a 500, you too right? > > Carl K > > omat wrote: > > As I further test the pythonic inheritance for models, I figure out > > that some django model magic does not work. For example, instead of > > "get_object_or_404" you should do: > > try: > > object = ObjectClass.objects.get(pk=1) > > except: > > raise Http404 > > > On 17 Temmuz, 18:01, omat <[EMAIL PROTECTED]> wrote: > >> Sorry for the terminological confusion. The "model" is the > >> django.db.models.Model() class, the "manager" is the > >> django.db.models.Manager() class. > > >> Yes Nis, the behaviors you listed are the most important ones. It > >> would be nice to have Meta, Admin, etc. inherited as well but, it is > >> not a priority. I think, with that requirements, pure pythonic class > >> inheritance is just fine. It gives a single table for each model, > >> which sounds quite natural. > > >> For the side effect, as Carl has pointed out, as long as you don't put > >> "ortho" in the settings.INSTALLED_APPS, it is not recognized by > >> syncdb. > > >> Yours, > >> oMat > > >> On 17 Temmuz, 17:14, Carl Karsten <[EMAIL PROTECTED]> wrote: > > >>> Nis Jørgensen wrote: > omat skrev: > > Thanks for the pointer, Nis. > > Model inheritance made my models so much DRYer that it will be hard to > > give up, at least psychologically... > > And, except for the managers, it worked just as I would expect, and > > for the managers, it was easy to patch. > Just to make sure I understand, your expected behavior is > - Each model gets a db table which include fields from its ancestors > - Managers and (other) methods are inherited as if they were defined on > the subclass > - There is no common interface for subclasses of a model class. > Correct? > I would perhaps call this "class templating" rather than "subclassing", > but I can definitely see its usefulness. > >>> I think the name problem stems from "model" not being well defined, or > >>> notr > >>> properly used. Is the model the class, the persistence implemented in > >>> the db, > >>> the shape of the data...? > >>> I agree that what is bing described here is very different than some of > >>> the > >>> other discussions that use the same terms. which makes it very > >>> confusing. (the > >>> other discussions seem to focus around a separate table for each level of > >>> subclass.) > >>> I am currently trying out what is discussed in this thread, and figured > >>> out the > >>> same hack: db_table = 'message' - Some time this week I hope to have > >>> things > >>> working well enough to post the whole app > >>> inhttp://groups.google.com/group/django-hotclub > Note that you get the probably undesired sideeffect of defining the > Ortho class as a model - which may cause some confusion if people use > syncdb and friends, and probably in other cases as well. > >>> So far syncdb has not found my abstract class. I have it in a separate > >>> dir not > >>> referenced by INSTALLED_APPS. guessing that is the trick, but I am not > >>> 100% > >>> sure how syncdb finds classes. > >>> Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: session question
On Wed, 2007-07-18 at 06:51 +, james_027 wrote: > hi, > > sorry for this stupid question ... does django's session only work > when cookies are enabled? That is correct. See http://www.djangoproject.com/documentation/sessions/#session-ids-in-urls for the documentation on this. Regards, Malcolm -- No one is listening until you make a mistake. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Logging in a newly created user
LaundroMat wrote: > Hi, > > When running this, I get a "NoneType has no attribute > is_authenticated()" error, and I cannot understand why: > > 1 new_user = User.objects.create_user(username, "your.email", > password) > 2 new_user.is_active = False > 3 new_user.save() > 4 user = authenticate(username = new_user.username, password = > new_user.password) # See http://code.djangoproject.org/ticket/2656 > 5 if user.is_authenticated(): # The error is produced here. > login(request, user) > > Why does authenticate() in line 4 return a None object instead of a > user? > > Thanks for your help, > > Mathieu "If the password is invalid, authenticate() returns None" [1] The password field in the User model contains "...a hash of, and metadata about, the password. (Django doesn't store the raw password.)" [2] So authenticate is returning None because you're trying to login with a hashed version of the password, not the raw version. Try this instead: user = authenticate(username=username, password=password) Look at the second code example under [1] for an example of how to do this. Jonathan. [1] http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in [2] http://www.djangoproject.com/documentation/authentication/#fields --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---