Re: Password Logistics Help Needed
Alright. I tried looking in the actual source for any mention of password_md5... and it no longer exists. So I'm sure I just can't call the field. I'd have to recreate it or something 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 -~--~~~~--~~--~--~---
Edit inline problems
Hi! It's been a while since I posted to this list, but I have a little problem and would like to ask for some help. I have the following 2 models: class Personnel(models.Model): report = models.ForeignKey(Report, unique = True) class Admin: pass def __str__(self): return 'Personnel list from (%s)' % self.report class Person(models.Model): personnel = models.ForeignKey( Personnel, core = True, edit_inline = models.TABULAR, min_num_in_admin = 1, max_num_in_admin = 10, ) first_name = models.CharField('F. Name', maxlength = 25, core = True) middle_name = models.CharField('M. Name', maxlength = 25, blank = True) last_name = models.CharField('L. Name', maxlength = 50) date_born = models.DateField() time_added = models.DateTimeField() def __str__(self): return '%s %s' % (self.first_name, self.last_name) I validate the models and I can see the forms in the Admin, but every time I try to add a Person (while adding a new Personnel list or editing an existing one), none of the Persons get saved. What could be wrong with my model? I'd appreciate your look at it and pointing any errors I might have in my code. Thank you! Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Password Logistics Help Needed
> The usual route I go with when trying to extend on the User model is > to create a new model and link it to the User model. For example: > > class UserExt(models.Model): > user = models.ForeignKey(User) > # ... other fields that you need here > > def __init__(self, user): > self.user = user > # ... other stuff that you need to do here > > # ... other methods you need here > > In your case, you can just create a UserExt model, add a password_md5 > field, set that field when creating or updating a user record and save > the user_ext object. Awesome, well I'm already extending the user model, so I can just add that. So password_md5 still exists? Sweet, if so, I can just override save() and have that save in the account table right? Things are looking a lot clearer now, thanks Nimrod. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: pydoc problem
On 6/27/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Looks like this is the default result for Model subclasses. Possibly > related to the way we create them (using a metaclass). Feel free to work > out a patch in django/db/models/base.py (in the ModelBase class, > probably) if you want to fix this. It would probably be useful. I've seen it happen as well, always on model classes. I need to check a newforms form and see if the same happens to them. -- "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: pydoc problem
On Wed, 2007-06-27 at 18:58 -0700, dailer wrote: > I have a models.py module that I thought I would test pydoc on. So I > try. > > > $ python manage.py shell > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole) > >>> from mysite.models import * > >>> help(Merchant) > Help on class Merchant in module mysite.models: > > Merchant = Looks like this is the default result for Model subclasses. Possibly related to the way we create them (using a metaclass). Feel free to work out a patch in django/db/models/base.py (in the ModelBase class, probably) if you want to fix this. It would probably be useful. Otherwise, might be worth opening a ticket in case somebody else is looking for something to do. > but this isn't the doc string I have for this class at all and isn't > what you normally get from pydoc. I try a few more of the classes with > the same result. So I copy one of those classes to a new class in the > same module (just adding the number 2 to the name) and it works > perfectly for that class. Obviously something somewhere else is > different but what? Given the complete lack of example code you've provided, we have no way of telling. Regards, Malcolm -- Despite the cost of living, have you noticed how popular it remains? 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: Newforms Attribute Errors
On Wed, 2007-06-27 at 12:05 -0700, robo wrote: [...] > -- > But even using custom forms I get errors: > > AttributeError at /vendor/Chef/1/ > 'lineItemPrice' object has no attribute 'save' > Request Method: POST > Request URL: http://192.168.1.104:8000/vendor/Chef/1/ > Exception Type: AttributeError > Exception Value: 'lineItemPrice' object has no attribute 'save' > Exception Location: /www/htdocs/gfs_chefrevival/../gfs_chefrevival/ > shop/views.py in vendor, line 131 > > This error shows up for EVERY form field in my forms.py (I've > commented out one by one). > > FYI, I'm using Django's development version (0.96-pre), could this be > a problem? If it says "0.96-pre" you aren't using the development version. You are using something from before the last release. However, even if you made a typo there and are really using 0.97-pre, there are no known huge bugs in the form handling code. Lots of people are using the development version. You are using some code that is at least a month or two old, though, since FloatField no longer takes max_digits and decimal_places in trunk. I have no guess as to what is going wrong here .You're just going to have use normal debugging techniques: put print statements into the code, for example and check that things are the types they should be. Read the Django source where it is failing and work out what it is expecting. Reduce your problem case to an example that is as small as possible so you don't have to worry about extra stuff getting in the way. Things like that. You are getting some fairly explicit error messages, so working out what is trying to call save() on a form field (and why) is going to go a long way towards solving this. Regards, Malcolm -- What if there were no hypothetical questions? 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: multiple databases
Hi Guys, I'm in the middle of the latest set of updates (the merge of the oracle branch with trunk), the only thing left to do is sort out the core.management module (68 conflicts!!). I should have that cracked by the end of today and it would be great to get it checked in so others could help with the testing... For some reason the tests are freezing my shell on my development machine! All of the changesets thus far have been done in an incremental way using a mirrored SVK repo, so I'm hopeful that I can commit them in a granular way too. If necessary I can make a patch against trunk, if commit access is problematic, although obviously we would lose all the log information if we did that. Let me know, Ben On Jun 27, 5:54 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> wrote: > On 6/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Ben Ford is working on merging in changes from the trunk in with the > > branch... at this time neither he or myself ( I had planned on doing > > this but found he was farther ahead of me ) have commit permissions to > > the project... but hopefully if he gets finished with it..and we can > > test it out... someone will give him permissions to commit. > > Email me and I'll give you guys commit privs. > > 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: lightTPD, local ref to static files
> Sorry, I don't know about fcgi configuration or url.rewrite-once. You can find docs about em here. http://www.djangoproject.com/documentation/fastcgi/ In my understanding, the Apache configuration would have the same problem. The issue is templates not being in the web root. Ivan On Jun 27, 9:15 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I have a lightTPD setup. Assume my django project is foo located at / > > home/foo, the document root is in /home/foo/public_html, and the > > django templates are in /home/foo/templates. > > > I've configured lightTPD as follows: > > === > > fastcgi.server = ( > > Sorry, I don't know about fcgi configuration or url.rewrite-once. > ... > > > By the way, my .com already exists, so it would be a nice if I could > > develop locally and use the former (foo.com/static/img.jpg) rather > > than use localhost. I should be able to configure my lightTPD to do > > that, right? > > If I understand you correctly, just have local lightty running and > edit /etc/hosts to resolve foo.com to (or whatever lightty is > listening on). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.contrib.auth: 'module' object has no attribute 'get_max_name_length'
On 6/28/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > It isn't a big problem, it will go away when you set DATABASE_NAME variable > in settings.py (the next step) and it will eventually be solved so the > behavior > matches the documentation again. FYI - I've fixed this in [5557]. 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: nested function
errr. i didn't do too well with my first post. Actually, my model validation calls startDate_EndDate_CrossValidation just find via a validator_list. The problem is I'm trying to write a tester and don't know how to call startDate_EndDate_CrossValidation and get field_data and all_data passed in. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: nested function
errr. i didn't do too well with my first post. Actually, my model validation calls startDate_EndDate_CrossValidation just find via a validator_list. The problem is I'm trying to write a tester and don't know how to call startDate_EndDate_CrossValidation and get field_data and all_data passed in. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: test client login problems
On 6/28/07, Chris Brand <[EMAIL PROTECTED]> wrote: > > > The 'bool object has no attribute status_code' message is generated > > because the login() method visits the named url, and tries to fill in > > the form it finds. If you are already logged in, and you visit a > > login-decorated view, the login form won't be shown - the underlying > > content will be shown. The login() test method returns true because a > > user is already logged in. > > Ahhh. So after I've used login() once in a test, get() will pass the > existing session cookie, in which case my test to retrieve two pages while > logged in would look like : > client.login(...) > client.get(...) > Does that sound right ? I'll try that later today. Sounds like you have the idea. 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: Password Logistics Help Needed
On 6/27/07, Bryan Veloso <[EMAIL PROTECTED]> wrote: > At the moment, the game can only read md5 or plain-text passwords, and > I know that Django has the hash$salt$hash (or something. :P) way of > doing it. So I can't just copy the password from the User model to the > account table since the game will choke on that data. So is there any > way I can store two sets of the password? One in the user model that > gets copied as md5 or plain-text to my accounts table? The usual route I go with when trying to extend on the User model is to create a new model and link it to the User model. For example: class UserExt(models.Model): user = models.ForeignKey(User) # ... other fields that you need here def __init__(self, user): self.user = user # ... other stuff that you need to do here # ... other methods you need here In your case, you can just create a UserExt model, add a password_md5 field, set that field when creating or updating a user record and save the user_ext object. HTH. -- _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 -~--~~~~--~~--~--~---
pydoc problem
I have a models.py module that I thought I would test pydoc on. So I try. $ python manage.py shell Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from mysite.models import * >>> help(Merchant) Help on class Merchant in module mysite.models: Merchant = but this isn't the doc string I have for this class at all and isn't what you normally get from pydoc. I try a few more of the classes with the same result. So I copy one of those classes to a new class in the same module (just adding the number 2 to the name) and it works perfectly for that class. Obviously something somewhere else is different but what? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Custom admin field widgets in the newforms-admin branch
On 6/27/07, leif strickland <[EMAIL PROTECTED]> wrote: > After some digging around, it looks like the newforms-admin branch > does not allow widget declarations within the model class itself. Yeah. As you've discovered, one of the big points of newforms-admin is to get as much stuff as possible out of the model -- it doesn't really belong there, and that's why you use a ModelAdmin class and register with an admin site. -- "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: freecomments not displayed II
Solved! I didn't know what was the problem, but when I cleaned up the whole project and tables (with startproject, startapp, syncdb) and copied again the code, it worked! On 27 jun, 12:00, emer77 <[EMAIL PROTECTED]> wrote: > (sorry for the bad english) > > I'm with the same problem of this (closed) > thread:http://groups.google.com/group/django-users/browse_thread/thread/9930... > > Using django-svn. > > In two local installations (Mac and Ubuntu), freecomments works > flawless (with "manage.py runserver"). > But at the server of webfaction, they don't show up, though the code > is the same. > > In the admin interface, the sum of comments appears, but the list is > empty. I checked at the phpMyAdmin: freecomments are there. > > Tried drop all tables and syncdb, but it didn't work. > > Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django.contrib.auth: 'module' object has no attribute 'get_max_name_length'
> Which DATABASE_BACKEND are you using? Are you running trunk, and if > so, what revision? I'm using MYSQL and trunk revision . As Ramiro said, it went away when I set the DATABASE_NAME, so I'm all set. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom admin field widgets in the newforms-admin branch
After some digging around, it looks like the newforms-admin branch does not allow widget declarations within the model class itself. However, adding a custom widget is quite easy. In the branch, almost all of the admin app functionality has been moved out of the inner Admin class and into a separate class called ModelAdmin. If you want to customize the admin app's behavior, simply subclass ModelAdmin and override the default functionality. For example, look at this sample ModelAdmin subclass: - from django.contrib import admin [...] class ProfileOptions(admin.ModelAdmin): list_display = ('display_name', 'headline','setup_date') filter_horizontal = ('techniques', 'products', 'setup') fields = (('Administrative Settings',{'fields': ('subscriber','active')}),('Contact Information',{'fields': ('phone_numbers','im_accounts','zip_code')}),('Photos',{'fields': ('primary_photo','secondary_photos','private_photos')}),) def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'zip_code': return ZipCodeField(**kwargs) else: return super(ProfileOptions,self).formfield_for_dbfield(db_field, **kwargs) def queryset(self, request): return self.model.user_profiles.get_query_set() adminsite.register(Profile,ProfileOptions) list_display and fields are used exactly as they were in inner Admin classes. filter_horizontal is simply a tuple of fields that will use the javascript multiple-select filter. The queryset() function allows you to specify which manager should be used to obtain the change list objects. Then there's formfield_for_dbfield(), a function that allows you to override the default form field types that are returned for your models' fields. In this example, the function returns a custom field class (ZipCodeField) for any model field named "zip_code". Alternatively, you could specify a custom widget like so: if db_field.name == 'zip_code': kwargs['widget'] = WIDGET return super(ProfileOptions,self).formfield_for_dbfield(db_field, **kwargs) Finally, don't forget to register your ModelAdmin subclass for the model. You can find more information on the branch's homepage: http://code.djangoproject.com/wiki/NewformsAdminBranch I hope this helps! If I am wrong about any of this, please post so others don't repeat my mistakes. Cheers, LS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin forms lose javascript with mod_python
Graham Dumpleton a écrit : > Do what has been suggested with using something like live http > headers, but in particular pay close attention to the Content-Type > header being returned for static files served from your /media > directory. When using Apache the content types for such files will be > dictated by Apache configuration and/or associated mime type files. It > is possible that Django in standalone mode returns something a little > different if it is serving up the static files in that case. thanks for both of your replies. I used wireshark (previously known as ethereal) to follow the HTTP stream (being a low-level type of guy, i tend to use low-level type of tools :) ). Saw that the js files were returning 404's, even though the css's weren't... It turns out i made a mistake in the apache/mod_python config. Because i serve multiple top-level urls from django, i use LocationMatch instead of Location, like so: SetHandler python-program PythonHandler django.core.handlers.modpython PythonInterpreter wwd SetEnv DJANGO_SETTINGS_MODULE wwd.settings PythonDebug On PythonPath "['/var/www/django','/var/www/django-projects'] + sys.path" well, the regex also catches, e.g., /media/js/admin/DateTimeShortcuts.js even though media is normally served statically. It doesn't catch the css media, though, because it's not in admin. Changing the regex to this: solves the problem nicely. PS: i use apache+mod_python simply because i have a few other apps that are raw mod_python, so i need apache+mod_python anyways - i might a well use it for django, too. -- __ Eric St-Jean[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: Newforms Attribute Errors
In python shell I typed: >> from gfs_chefrevival.shop.forms import OrderDetailForm >> from django import newforms as forms >> f = OrderDetailForm() >> f.is_bound I get the error: Traceback (most recent call last): File "", line 1, in ? AttributeError: 'lineItemPrice' object has no attribute 'is_bound' >>> What's the problem? Can anyone tell me? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: lightTPD, local ref to static files
On 6/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a lightTPD setup. Assume my django project is foo located at / > home/foo, the document root is in /home/foo/public_html, and the > django templates are in /home/foo/templates. > > I've configured lightTPD as follows: > === > fastcgi.server = ( Sorry, I don't know about fcgi configuration or url.rewrite-once. ... > By the way, my .com already exists, so it would be a nice if I could > develop locally and use the former (foo.com/static/img.jpg) rather > than use localhost. I should be able to configure my lightTPD to do > that, right? If I understand you correctly, just have local lightty running and edit /etc/hosts to resolve foo.com to (or whatever lightty is listening on). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.contrib.auth.views
On 6/27/07, rycole <[EMAIL PROTECTED]> wrote: > Or, will these views stay backwards compatible through > future versions? These views provided by auth are exactly what I need, > but I don't want to use them if I will need to change stuff later. Any > ideas? I'm pretty sure they'll be updated to newforms, but to be clear, your choices are to either use what's there and works for now (with likely migration in the future), or roll your own for sure right now. I'd use what's there. ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
nested function
I created a validator for use in a validator_list in the admin interface like so... def startDate_EndDate_CrossValidation(modelName): def result(field_data, all_data): being new to python, I stole this from an example somewhere. I have these 3 attributes, but how do I call this? I tried following the django code, but it's a bit over my head at this point. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin and .FileField()
Took me a bit to get .FileField() working in the admin, and im wondering if it needs to be as complicated as it seems. I think it currently violates DRY, and maybe that was intentional for 'security' or 'performance' reasons, or maybe it was just an oversight. I did the following, and got the following. [EMAIL PROTECTED]:~/django$ django-admin.py startproject filez [EMAIL PROTECTED]:~/django/filez$ ./manage.py startapp pics DATABASE_ENGINE = 'mysql' db, user, pass ... INSTALLED_APPS = ( 'django.contrib.admin', 'filez.pics', # models.py from django.db import models class File(models.Model): attachment = models.FileField(upload_to='attaches', blank=True ) class Admin: pass # urls.py # Uncomment this for admin: (r'^admin/', include('django.contrib.admin.urls')), http://dell29:8000/admin/pics/file/add/ Give it a file name (text box or browse button) hit Save. (it will create the attaches dir. not sure if that is a good thing or not. personally I would rather it error, but at least it makes it obvious where the dir 'is'.) http://dell29:8000/admin/pics/file/1/ source: attaches/P1010001.JPG which is: http://localhost:8000/admin/pics/file/1/attaches/P1010001.JPG click that, get 404, Using the URLconf defined in filez.urls, Django tried these URL patterns, in this order: ... The current URL, admin/pics/file/1/attaches/P1010001.JPG, didn't match any of these. As in, it can't find where it put it. Seems to me the default should be to be able to figure that out. With some help from #django I did get it working, but it didn't seem 'right.' so I figured I would throw up a flag and see if anyone thinks some tweaks need to happen, or point to the docs that show me how to do this the easy way. 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: Announcing the birth of Fluther.com
Looks great. Good work! For those of us still stuck in alpha, can you share a bit about your implementation? Are you using Apache? Squid? What's your approach to caching? Did you use Django's built-in User model for your registered site users? What DB did you opt for? Any information would be a great help to all the Django newbies. Plus, you might get some valuable feedback from the pros on this board. Again, congrats! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
fyi
http://www.oreillynet.com/onlamp/blog/2007/06/python_web_application_framewo.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Zip code lookup field
I figured it out! The problem was that my custom zip code field's clean() function was returning the profile object's *id*, not the actual zip code instance. > zip_code_id = Postal_Code.objects.get(postal_code=value).id > return int(zip_code_id) As it turns out, the function should have returned the actual object. All I had to do to make this code work, therefore, was remove the ".id" from the end of the first line above. Voila! Lesson learned: Custom fields for foreign keys must return an instance, not the key. Thanks again for the help. Hope this thread helps someone else in the future. Cheers, LS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Password Logistics Help Needed
Alright, I did about 2 hours of searching today and I'm beginning to think that the above is an impossibility. Which probably means that I'm going to have to bypass Django authentication and make my own, but I don't even know where to start on that, so I'm at quite a loss. :/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
Anyway I'd also like to add that having built my first real application with Django I'm awestruck at how easy it is to use. I spent more time picking colors that looked good together than I did coding site logic. On top of that, the source of the package is easy to read and which makes up for the documentation (which has gotten better though). On Jun 27, 6:45 pm, Ryan K <[EMAIL PROTECTED]> wrote: > Right but I'm using the Django server included with the package for > development and Apache for another. So the root of my test server is / > mydjangosite, but for my deployment server its /~ryan/...etc..etc > I just put a LINK_PREFIX string in the top settings module and a > wrapper function like add_site_context(other_context) that returns > this setting along with any other extra context stuff for use with > templates. > > On Jun 27, 5:45 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > I just make them all come from the root. Works no matter where it's > > deployed: > > Instead of "http://example.com/mydjangosite/manage/manage; I would > > just do "/mydjangosite/manage/manage" > > > On Jun 27, 2:41 pm, Ryan K <[EMAIL PROTECTED]> wrote: > > > > What if I am using generic views? > > > > On Jun 27, 3:26 pm, Ryan K <[EMAIL PROTECTED]> wrote: > > > > > Perfect. Thanks. > > > > > On Jun 27, 12:40 pm, Thomas Steinacher <[EMAIL PROTECTED]> wrote: > > > > > > Try the {% url %} > > > > > tag:http://www.djangoproject.com/documentation/templates/#url > > > > > > tom > > > > > > On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > > > > > > What is the best form of a link in my Django site's templates? For > > > > > > example, I have a base.html which serves as the base template for > > > > > > all > > > > > > others. It contains links that are relative to the current directory > > > > > > like Manage. However, when I am at a page > > > > > > like > > > > > >http://example.com/mydjangosite/manage/edit/23123(editingtheobject > > > > > > with id 23123) the same link above is instead pointing to > > > > > >http://example.com/mydjangosite/manage/manage. I constantly have to > > > > > > deploy this application to the main server but normally I work on it > > > > > > locally, so absolute links would be a pain. Should I use templated > > > > > > URLs (e.g. Manage) for my links > > > > > > or > > > > > > is there a better way? > > > > > > > Thanks, > > > > > > Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
lightTPD, local ref to static files
Hi, I have a lightTPD setup. Assume my django project is foo located at / home/foo, the document root is in /home/foo/public_html, and the django templates are in /home/foo/templates. I've configured lightTPD as follows: === fastcgi.server = ( "/django.fcgi" => ( "main" => ( #"socket" => "/home/foo/django.socket" "host" => "127.0.0.1", "port" => 3033, ) ), "/admin.fcgi" => ( "admin" => ( #"socket" => "/home/foo/admin.socket" "host" => "127.0.0.1", "port" => 3034, ) ) ) alias.url = ( "/media/" => "/usr/lib/python2.5/site-packages/django/contrib/ admin/media/", ) url.rewrite-once = ( "^(/media.*)$" => "$1", "^(/static.*)$" => "$1", "^/favicon\.ico$" => "/media/favicon.ico", "^(/admin/.*)$" => "/admin.fcgi$1", "^(/.*)$" => "/django.fcgi$1" ) === Note that static listing in url.rewrite-once. I want to put my javascript, images, and css in public_html/static. The problem seems to come with the templates. I want to be able to say . But that seems to want to look in /home/foo/templates/myView/static/ img.jpg. That sucks. I don't want to have to say . I also don't want to say when developing locally. Any solutions? By the way, my .com already exists, so it would be a nice if I could develop locally and use the former (foo.com/static/img.jpg) rather than use localhost. I should be able to configure my lightTPD to do that, right? Thanks! Ivan Kirigin www.kirigin.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: Announcing the birth of Fluther.com
Very well done. Michael On 6/27/07, Andrew <[EMAIL PROTECTED]> wrote: > > Hello Fellow Djangoers! > > After many late-night IRC sessions and countless visits to the django > docs, we're very proud to announce the launch of Fluther.com, our > Django-powered social Q site. > > Yes, it's similar to Yahoo Answers or AskMeFi, but with some new > twists like real-time discussion, questions filtered for you, and IM > integration. > > Now that we have finally completed it we're climbing out from our cave > and wondering if the site can fly, and how we help attract people to > it. > > Any comments or advice? > > Andrew McClain > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: gettatr() access to ManyToMany huuuge delay?
On Jun 27, 11:32 pm, grassoalvaro <[EMAIL PROTECTED]> wrote: > Here some code: > - > class TestField(models.Model): > name = models.TextField() > text = models.ManyToManyField(TextOption) > class Meta: > db_table = 'test' > > test = TestField.objects.get() > a = time.time() > for i in range(0, 1): > t = getattr(test, "text") > print "text: %f"%(time.time()-a) > a = time.time() > for i in range(0, 1): > t = getattr(test, "name") > print "name: %f"%(time.time()-a) > > text: 1.149759 > name: 0.017819 > - > > Can someone explain me, why when i'm doing gettatr(test, "text") > (ManyToMany) i have so long delay? That is django (not database) > problem but i really don't know why. Anyone? Doesn't it depend on server ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
ManyToManyField: help_text missing when using filter_interface
Greetings, When I use a filter_interface for ManyToManyFields that have help_text set, the help does not show up in the admin interface. I have started to dig into the Javascript that makes the change for the select box, but hopefully someone can identify the problem more quickly than I. The other thing I noticed while researching the problem. In the documentation on "Customizing the Django admin interface", the Labels section says, "Any explanation or help text should follow the label in a p with class .help." In the source code of the rendered page without any customization, the help_text shows up at the end of the "form-row" div tag rather than after the label. I am using version 0.96 on SuSE 10.1 with Python 2.4.2. Thanks. Carlos Hanson --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Announcing the birth of Fluther.com
Hello Fellow Djangoers! After many late-night IRC sessions and countless visits to the django docs, we're very proud to announce the launch of Fluther.com, our Django-powered social Q site. Yes, it's similar to Yahoo Answers or AskMeFi, but with some new twists like real-time discussion, questions filtered for you, and IM integration. Now that we have finally completed it we're climbing out from our cave and wondering if the site can fly, and how we help attract people to it. Any comments or advice? Andrew McClain --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
Here's a bit of the testing I have run in the shell... >>> from mysite2.profile.models import Profile >>> from django import newforms >>> from mysite2.admin import ProfileOptions >>> # instantiate a Profile object >>> test_profile = Profile.objects.get(id=1) >>> # instantiate the adminoptions class >>> # used by the admin site >>> options = ProfileOptions(Profile) >>> # create a form class for the profile instance >>> form = newforms.form_for_instance(test_profile,formfield_callback = >>> options.formfield_for_dbfield) >>> form >>> # check that the zip_code field is of type ZipCodeField >>> form.base_fields['zip_code'] >>> # in my database, i currently have only one zip code >>> # 90069, with a key of 1. >>> form.base_fields['zip_code'].initial 1 >>> form.base_fields['zip_code'].clean(value='90069') 1 >>> form.base_fields['zip_code'].clean(value='111') Traceback (most recent call last): File "", line 1, in ? File "Sites/Django/mysite2/../mysite2/admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> form.base_fields['zip_code'].clean(value='') Traceback (most recent call last): File "", line 1, in ? File "/Users/leifstrickland/Sites/DjangoProject/mysite2/../mysite2/ admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> zip_code_field = form.base_fields['zip_code'] >>> zip_code_field.widget.render(name='zip_code',value=1) u'' >>> zip_code_field.widget.render(name='zip_code',value='') u'' As you can see, everything seems to be working. I'm so puzzled... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
Here's a bit of the testing I have run in the shell... >>> from mysite2.profile.models import Profile >>> from django import newformms >>> from mysite2.admin import ProfileOptions >>> >>> # instantiate a Profile object >>> test_profile = Profile.objects.get(id=1) >>> >>> # instantiate the adminoptions class >>> # used by the admin site >>> options = ProfileOptions(Profile) >>> >>> # create a form class for the profile instance >>> form = newforms.form_for_instance(test_profile,formfield_callback = >>> options.formfield_for_dbfield) >>> form >>> >>> # check that the zip_code field is of type ZipCodeField >>> form.base_fields['zip_code'] >>> >>> # in my database, i currently have only one zip code >>> # 90069, with a key of 1. >>> >>> form.base_fields['zip_code'].initial 1 >>> >>> form.base_fields['zip_code'].clean(value='90069') 1 >>> >>> form.base_fields['zip_code'].clean(value='111') Traceback (most recent call last): File "", line 1, in ? File "Sites/Django/mysite2/../mysite2/admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> >>> form.base_fields['zip_code'].clean(value='') Traceback (most recent call last): File "", line 1, in ? File "/Users/leifstrickland/Sites/DjangoProject/mysite2/../mysite2/ admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> >>> zip_code_field = form.base_fields['zip_code'] >>> zip_code_field.widget.render(name='zip_code',value=1) u'' >>> >>> zip_code_field.widget.render(name='zip_code',value='') u'' As you can see, everything seems to be working. I'm so puzzled... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Method to find the admin url for an object
> If you're wanting it for actual inclusion, there's also the edge case > of whether the model's been saved. If not PK is None, and the URL > will be mal-formed. > > I dunno what to do for that corner case. I guess it might make sense to return the "add" url instead, although that makes it twice as much code. I don't think that's an issue for me (yet). As for whether it should be part of models.Model, I'm not particularly bothered either way, but in favour are : 1. The fact that it doesn't require any info outside the model itself, 2. The fact that I'm not the only person who found a need for it - Nathaniel has one, and he credits wamber.net. Against is the corner case you mention, of course. I suppose I should add it to trac to let the experts decide. Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
Right but I'm using the Django server included with the package for development and Apache for another. So the root of my test server is / mydjangosite, but for my deployment server its /~ryan/...etc..etc I just put a LINK_PREFIX string in the top settings module and a wrapper function like add_site_context(other_context) that returns this setting along with any other extra context stuff for use with templates. On Jun 27, 5:45 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I just make them all come from the root. Works no matter where it's > deployed: > Instead of "http://example.com/mydjangosite/manage/manage; I would > just do "/mydjangosite/manage/manage" > > On Jun 27, 2:41 pm, Ryan K <[EMAIL PROTECTED]> wrote: > > > What if I am using generic views? > > > On Jun 27, 3:26 pm, Ryan K <[EMAIL PROTECTED]> wrote: > > > > Perfect. Thanks. > > > > On Jun 27, 12:40 pm, Thomas Steinacher <[EMAIL PROTECTED]> wrote: > > > > > Try the {% url %} > > > > tag:http://www.djangoproject.com/documentation/templates/#url > > > > > tom > > > > > On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > > > > > What is the best form of a link in my Django site's templates? For > > > > > example, I have a base.html which serves as the base template for all > > > > > others. It contains links that are relative to the current directory > > > > > like Manage. However, when I am at a page like > > > > >http://example.com/mydjangosite/manage/edit/23123(editingtheobject > > > > > with id 23123) the same link above is instead pointing to > > > > >http://example.com/mydjangosite/manage/manage. I constantly have to > > > > > deploy this application to the main server but normally I work on it > > > > > locally, so absolute links would be a pain. Should I use templated > > > > > URLs (e.g. Manage) for my links or > > > > > is there a better way? > > > > > > Thanks, > > > > > Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Method to find the admin url for an object
On 6/27/07, Chris Brand <[EMAIL PROTECTED]> wrote: ... > Hmmm. Nice, except that it hardcodes the base url of the admin, which leads > me to this : If you're wanting it for actual inclusion, there's also the edge case of whether the model's been saved. If not PK is None, and the URL will be mal-formed. I dunno what to do for that corner case. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Method to find the admin url for an object
> Small tweak to support models which don't use AutoField for primary_key. > > def get_admin_url(self): >pk = getattr(self, self._meta.pk.attname) >return "/admin/%s/%s/%s/" % ( > self._meta.app_label, > self._meta.module_name, > pk) Hmmm. Nice, except that it hardcodes the base url of the admin, which leads me to this : def get_admin_url(self): pk = getattr(self, self._meta.pk.attname) return ('django.contrib.admin.views.main.change_stage', (self._meta.app_label, self._meta.module_name, pk)) get_admin_url = models.permalink(get_admin_url) Does that look reasonable? Looks like something that could be part of models.Model... Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django.contrib.auth.views
I'm beginning a site with Django, and am starting with the fundamental elements of the site first. I figured I'd get the user login / registration working before I do anything. Should I still use django.contrib.auth.views for login, logout, etc, even though they use oldforms? Or, will these views stay backwards compatible through future versions? These views provided by auth are exactly what I need, but I don't want to use them if I will need to change stuff later. Any ideas? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Zip code lookup field
Yes, the ModelAdmin is registered with django.contrib.admin.site. And the change and add pages for the model are displaying correctly. It even provides the expected error message if I enter an invalid Zip code. But when I enter a correct Zip code and Save, it gives me an Integrity Error: --- IntegrityError at /admin/profile/profile/2/ null value in column "zip_code_id" violates not-null constraint TRACEBACK /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/core/handlers/base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/sites.py in root return self.model_page(request, *url.split('/', 2)) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/sites.py in model_page return admin_obj(request, rest_of_url) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in __call__ return self.change_view(request, unquote(url)) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in change_view return self.save_change(request, model, form, inline_formsets) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in save_change new_object = form.save(commit=True) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/newforms/models.py in save return save_instance(self, instance, fields, fail_message, commit) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/newforms/models.py in save_instance instance.save() ... /Sites/Django/mysite2/../mysite2/profile/models.py in save super(Profile, self).save() ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/db/models/base.py in save db_values + [pk_val]) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/db/backends/util.py in execute return self.cursor.execute(sql, params) ... --- In the last step, the local db_values var is a tuple of values to be used in the DB query. All values are correct except for the zip_code_id, which is None. That shouldn't be the case, because the zip code field's clean() function has worked properly (i.e., returned the corresponding zip_code_id) in shell and admin testing. So somehow the value returned by the clean() function is being overwritten or ignored later in the script. I just can't figure it out. Thanks again for all the help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Zip code lookup field
Yes, the ModelAdmin is registered with django.contrib.admin.site. And the change and add pages for the model are displaying correctly. It even provides the expected error message if I enter an invalid Zip code. But when I enter a correct Zip code and Save, it gives me an Integrity Error: --- IntegrityError at /admin/profile/profile/2/ null value in column "zip_code_id" violates not-null constraint TRACEBACK /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/core/handlers/base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/sites.py in root return self.model_page(request, *url.split('/', 2)) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/sites.py in model_page return admin_obj(request, rest_of_url) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in __call__ return self.change_view(request, unquote(url)) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in change_view return self.save_change(request, model, form, inline_formsets) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/contrib/admin/options.py in save_change new_object = form.save(commit=True) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/newforms/models.py in save return save_instance(self, instance, fields, fail_message, commit) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/newforms/models.py in save_instance instance.save() ... /Users/leifstrickland/Sites/DjangoProject/mysite2/../mysite2/profile/ models.py in save super(Profile, self).save() ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/db/models/base.py in save db_values + [pk_val]) ... /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/django/db/backends/util.py in execute return self.cursor.execute(sql, params) ... --- In the last step, the local db_values var is a tuple of values to be used in the DB query. All values are correct except for the zip_code_id, which is None. That shouldn't be the case, because the zip code field's clean() function has worked properly (i.e., returned the corresponding zip_code_id) in shell and admin testing. So somehow the value returned by the clean() function is being overwritten or ignored later in the script. I just can't figure it out. Thanks again for all the help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Method to find the admin url for an object
On 6/27/07, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > > def get_admin_url(self): > return "%s/%s/%s/%s/" % ("/admin", self._meta.app_label, Small tweak to support models which don't use AutoField for primary_key. def get_admin_url(self): pk = getattr(self, self._meta.pk.attname) return "/admin/%s/%s/%s/" % ( self._meta.app_label, self._meta.module_name, pk) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
I just make them all come from the root. Works no matter where it's deployed: Instead of "http://example.com/mydjangosite/manage/manage; I would just do "/mydjangosite/manage/manage" On Jun 27, 2:41 pm, Ryan K <[EMAIL PROTECTED]> wrote: > What if I am using generic views? > > On Jun 27, 3:26 pm, Ryan K <[EMAIL PROTECTED]> wrote: > > > Perfect. Thanks. > > > On Jun 27, 12:40 pm, Thomas Steinacher <[EMAIL PROTECTED]> wrote: > > > > Try the {% url %} > > > tag:http://www.djangoproject.com/documentation/templates/#url > > > > tom > > > > On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > > > > What is the best form of a link in my Django site's templates? For > > > > example, I have a base.html which serves as the base template for all > > > > others. It contains links that are relative to the current directory > > > > like Manage. However, when I am at a page like > > > >http://example.com/mydjangosite/manage/edit/23123(editingtheobject > > > > with id 23123) the same link above is instead pointing to > > > >http://example.com/mydjangosite/manage/manage. I constantly have to > > > > deploy this application to the main server but normally I work on it > > > > locally, so absolute links would be a pain. Should I use templated > > > > URLs (e.g. Manage) for my links or > > > > is there a better way? > > > > > Thanks, > > > > Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
On 6/27/07, leif strickland <[EMAIL PROTECTED]> wrote: ... > zip_code_id = > Postal_Code.objects.get(postal_code=value).id Is Postal_Code.postal_code a string or numeric? ... > try: > zip_code = Postal_Code.objects.get(id = > value).postal_code > except: > zip_code = value Again, you may want to str() .postal_code if it's numeric. Are you registering your custom ModelAdmin with django.contrib.admin.site? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 URL
Yes, Alberto is right. Also, I ran into this problem a few days ago. Basically, after you write your view processing like Alberto suggested, you need to do a response redirect or HttpResponseRedirect and pass it "." (which is to the same page the user was on). After I did that on my form, the user gets sent back to the same page and the "." eliminates concatenating another useradd string to the end of your url. Have fun. On Jun 27, 1:19 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > Hello, > > On Jun 27, 10:55 am, AnaReis <[EMAIL PROTECTED]> wrote: > > > Hi, > > I'm having a problem here and I don't really know how to solve it. > > I have a form on a page, the add user page: > > (r'^manager/operations/nlsciadc/users/adduser/$', add_user), #The > > template is add_user.html > > > When the user presses submit, the action on the form sends the user > > to: > > > > the best practice is to use the same view to display (GET request) and > process (POST request) the form. This is shown > here:http://www.djangoproject.com/documentation/newforms/#simple-view-example > > This way you redisplay the same page when the form is not valid, and > redirect to another page upon successful form submission. > > If something is not clear, feel free to ask again. > > Bye, > > Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
gettatr() access to ManyToMany huuuge delay?
Here some code: - class TestField(models.Model): name = models.TextField() text = models.ManyToManyField(TextOption) class Meta: db_table = 'test' test = TestField.objects.get() a = time.time() for i in range(0, 1): t = getattr(test, "text") print "text: %f"%(time.time()-a) a = time.time() for i in range(0, 1): t = getattr(test, "name") print "name: %f"%(time.time()-a) text: 1.149759 name: 0.017819 - Can someone explain me, why when i'm doing gettatr(test, "text") (ManyToMany) i have so long delay? That is django (not database) problem but i really don't know why. Anyone? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Method to find the admin url for an object
Not sure if this is what you're looking for, or if there's an official way to to this, but I'm using this:: def get_admin_url(self): return "%s/%s/%s/%s/" % ("/admin", self._meta.app_label, self._meta.object_name.lower(), self.id) Stolen from wamber.net. - whiteinge On Jun 27, 11:10 am, "Chris Brand" <[EMAIL PROTECTED]> wrote: > In going through cleaning up all the hard-coded urls in my templates, I'm > making good use of the get_absolute_url methods that I've added to my > models. > > Looking at the links I'm left with, they're almost all to the admin pages. > How would I write a method to provide a get_admin_change_url method ? > > Thanks, > > Chris Brand --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
OK, I've been tinkering with this all day, and I'm still having one big problem As Jeremy suggested, I created custom ZipCodeField and MyAdmin classes. In addition, I created a custom ZipcodeLookupInput widget. I've tested this in the shell and on the test server, and the clean and render functions appear to be working beautifully. The widget's render() function looks up the initial value (the zip code id) and uses the corresponding zip code as its display value, and the field's clean() function converts the user-provided zip into an id and returns it as an integer value. Unfortunately, I keep getting an error when I try to save. It appears that the zip_code_id is None by the time a DB query is attempted in django.db.backends.util. But this makes no sense, beacuse the clean() function seems to be working properly (i.e., it returns an integer value). Does anyone know what might be happening? I have pasted my custom classes code below. from mysite.address.models import Postal_Code from django import newforms as forms [...] class ProfileOptions(admin.ModelAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'zip_code': return ZipCodeField(**kwargs) else: return super(ProfileOptions,self).formfield_for_dbfield(db_field, **kwargs) class ZipCodeField(forms.fields.CharField): def __init__(self, **kwargs): kwargs['widget'] = ZCLookupTextInput self.max_length, self.min_length = 5, 5 super(ZipCodeField, self).__init__(**kwargs) def clean(self, value): super(ZipCodeField, self).clean(value) try: zip_code_id = Postal_Code.objects.get(postal_code=value).id except Postal_Code.DoesNotExist: raise ValidationError, "Please enter a valid zip code." return int(zip_code_id) class ZCLookupTextInput(forms.widgets.TextInput): def render(self, name, value, attrs=None): try: zip_code = Postal_Code.objects.get(id = value).postal_code except: zip_code = value return super(ZCLookupTextInput, self).render(name, zip_code, attrs) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
OK, I've been tinkering with this all day, and I'm still having one big problem As Jeremy suggested, I created custom ZipCodeField and MyAdmin classes. In addition, I created a custom ZipcodeLookupInput widget. I've tested this in the shell and on the test server, and the clean and render functions appear to be working beautifully. The widget's render() function looks up the initial value (the zip code id) and uses the corresponding zip code as its display value, and the field's clean() function converts the user-provided zip into an id and returns it as an integer value. Unfortunately, I keep getting an error when I try to save. It appears that the zip_code_id is None by the time a DB query is attempted in django.db.backends.util. But this makes no sense, beacuse the clean() function seems to be working properly (i.e., it returns an integer value). Does anyone know what might be happening? I have pasted my custom classes code below. from mysite.address.models import Postal_Code from django import newforms as forms [...] class ProfileOptions(admin.ModelAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'zip_code': return ZipCodeField(**kwargs) else: return super(ProfileOptions,self).formfield_for_dbfield(db_field, **kwargs) class ZipCodeField(forms.fields.CharField): def __init__(self, **kwargs): kwargs['widget'] = ZCLookupTextInput self.max_length, self.min_length = 5, 1 super(ZipCodeField, self).__init__(**kwargs) def clean(self, value): super(ZipCodeField, self).clean(value) try: zip_code_id = Postal_Code.objects.get(postal_code=value).id except Postal_Code.DoesNotExist: raise ValidationError, "Please enter a valid zip code." return int(zip_code_id) class ZCLookupTextInput(forms.widgets.TextInput): def render(self, name, value, attrs=None): try: zip_code = Postal_Code.objects.get(id = value).postal_code except: zip_code = value return super(LookupTextInput, self).render(name, zip_code, attrs) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Re-rendering same page
Specifically, the boolean values describe certain types of data the user wishes to mask when looking through the database. The values are specific to each user, so there is no reason to DB them. I am storing them in the session variable. The problem is that the variables are not updated instantly, and I was wondering why this could be. On Jun 27, 2:06 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/27/07, Val <[EMAIL PROTECTED]> wrote: > ... > > >change a boolean > > value > > A boolean value where, in what context, for what purpose? > > > it > > takes multiple refreshes for the value to update itself. > > There are multiple processes in general-- runserver is one process, > but shouldn't be used outside of development. > > If you're setting a value you wish to be shared amongst multiple > requests, you need to put it out of process somehow. Cache or DB are > the general answers. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 URL
Hello, On Jun 27, 10:55 am, AnaReis <[EMAIL PROTECTED]> wrote: > Hi, > I'm having a problem here and I don't really know how to solve it. > I have a form on a page, the add user page: > (r'^manager/operations/nlsciadc/users/adduser/$', add_user), #The > template is add_user.html > > When the user presses submit, the action on the form sends the user > to: > the best practice is to use the same view to display (GET request) and process (POST request) the form. This is shown here: http://www.djangoproject.com/documentation/newforms/#simple-view-example This way you redisplay the same page when the form is not valid, and redirect to another page upon successful form submission. If something is not clear, feel free to ask again. Bye, Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 tag render method never called
I have determined the source of my problem. It was an inheriting template defining a block and shadowing the parent block in which my tag was called. On Jun 27, 1:44 pm, Kevin Tonon <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using Django 0.91 > > More or less, this is what I'm doing: > > appname/templatetags/app_extras.py: > > from django.core.template import Library, Node > register = Library() > > class MyNode(Node): > def __init__(self, foo): > self.foo = foo > print 'foo' * 100 > > def render(self, context): > print 'bar' * 100 > return 'bar' * 100 > > @register.tag > def mytag(parser, token): > return MyNode(0) > > In my template: > {% load app_extras %} > {% mytag %} > > When I run this using the development server, 'foo' * 100 is printed, > but 'bar' * 100 is not. That is, it looks like render is never being > called? Is there anything obviously wrong with what I'm doing? > > On another note, I tried stepping through the code with pdb, but it > was ignoring my breakpoints. I tried running the server with -- > noreload too, but 0.91 doesn't seem to support that. > > Any advice would be greatly appreciated, thanks. > Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.contrib.auth: 'module' object has no attribute 'get_max_name_length'
On 6/27/07, BigBaaadBob <[EMAIL PROTECTED]> wrote: > > New install and new user, so maybe I'm doing something dumb. I > searched and didn't see anything... > > Following the tutorial I get this when running the development server: > > [EMAIL PROTECTED] ~/DjangoText/demosite $ python manage.py runserver > Validating models... > django.contrib.auth: 'module' object has no attribute > 'get_max_name_length' > 1 error found. > > Django version 0.97-pre, using settings 'demosite.settings' > Development server is running at http://127.0.0.1:8000/ > Quit the server with CONTROL-C. > > This is on Gentoo with dev-lang/python-2.4.4-r4 > This is related to this ticket: http://code.djangoproject.com/ticket/4689 Don't let the message/error intimidate you and go on with the tutorials :). It isn't a big problem, it will go away when you set DATABASE_NAME variable in settings.py (the next step) and it will eventually be solved so the behavior matches the documentation again. Regards, -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
What if I am using generic views? On Jun 27, 3:26 pm, Ryan K <[EMAIL PROTECTED]> wrote: > Perfect. Thanks. > > On Jun 27, 12:40 pm, Thomas Steinacher <[EMAIL PROTECTED]> wrote: > > > Try the {% url %} > > tag:http://www.djangoproject.com/documentation/templates/#url > > > tom > > > On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > > > What is the best form of a link in my Django site's templates? For > > > example, I have a base.html which serves as the base template for all > > > others. It contains links that are relative to the current directory > > > like Manage. However, when I am at a page like > > >http://example.com/mydjangosite/manage/edit/23123(editingthe object > > > with id 23123) the same link above is instead pointing to > > >http://example.com/mydjangosite/manage/manage. I constantly have to > > > deploy this application to the main server but normally I work on it > > > locally, so absolute links would be a pain. Should I use templated > > > URLs (e.g. Manage) for my links or > > > is there a better way? > > > > Thanks, > > > Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.contrib.auth: 'module' object has no attribute 'get_max_name_length'
New install and new user, so maybe I'm doing something dumb. I searched and didn't see anything... Following the tutorial I get this when running the development server: [EMAIL PROTECTED] ~/DjangoText/demosite $ python manage.py runserver Validating models... django.contrib.auth: 'module' object has no attribute 'get_max_name_length' 1 error found. Django version 0.97-pre, using settings 'demosite.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. This is on Gentoo with dev-lang/python-2.4.4-r4 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Re-rendering same page
On 6/27/07, Val <[EMAIL PROTECTED]> wrote: > > Specifically, the boolean values describe certain types of data the > user wishes to mask when looking through the database. The values are > specific to each user, so there is no reason to DB them. I am storing > them in the session variable. The session variable (I assume you mean request.session) is backed by the database, fetched upon the first access and stored back at the end of each request. > The problem is that the variables are > not updated instantly, and I was wondering why this could be. Are you serving multiple requests by the same user at the same 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 -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
Perfect. Thanks. On Jun 27, 12:40 pm, Thomas Steinacher <[EMAIL PROTECTED]> wrote: > Try the {% url %} > tag:http://www.djangoproject.com/documentation/templates/#url > > tom > > On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > > > > What is the best form of a link in my Django site's templates? For > > example, I have a base.html which serves as the base template for all > > others. It contains links that are relative to the current directory > > like Manage. However, when I am at a page like > >http://example.com/mydjangosite/manage/edit/23123(editing the object > > with id 23123) the same link above is instead pointing to > >http://example.com/mydjangosite/manage/manage. I constantly have to > > deploy this application to the main server but normally I work on it > > locally, so absolute links would be a pain. Should I use templated > > URLs (e.g. Manage) for my links or > > is there a better way? > > > Thanks, > > Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 Attribute Errors
I've also tried abandoning form_for_model and created my own custom form like so in forms.py: from django import newforms as forms from django.newforms.widgets import * class OrderDetailForm(forms.Form): order = forms.IntegerField() quantity = forms.IntegerField() unitPrice = FloatField(label='Price', max_digits=10, decimal_places=2) lineItemPrice = FloatField(label='Line Item Price', required=False, max_digits=10, decimal_places=2) item = forms.IntegerField() size = forms.ChoiceField(choices=SIZE) timestamp = forms.DateTimeField(required=False) vendor = forms.IntegerField() -- Then in my view: from django.shortcuts import render_to_response, get_object_or_404 from django.contrib import * from gfs_chefrevival.store.models import * from gfs_chefrevival.shop.forms import OrderDetailForm from gfs_chefrevival.products.models import * from gfs_chefrevival.vendors.models import Vendor from django.contrib.auth.models import User from django.http import * from django import newforms as forms import datetime detail_form_data = { #'timestamp': datetime.datetime.now(), 'vendor': vendor_id, 'unitPrice': 5.23, 'lineItemPrice': 1.90, 'quantity': 1, 'order': 1, 'size': "M", 'item': 5 } def vendor(request, vendor_name, vendor_id): if request.method == 'POST': form = OrderDetailForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(".") else: form = OrderDetailForm(detail_form_data) -- But even using custom forms I get errors: AttributeError at /vendor/Chef/1/ 'lineItemPrice' object has no attribute 'save' Request Method: POST Request URL: http://192.168.1.104:8000/vendor/Chef/1/ Exception Type: AttributeError Exception Value: 'lineItemPrice' object has no attribute 'save' Exception Location: /www/htdocs/gfs_chefrevival/../gfs_chefrevival/ shop/views.py in vendor, line 131 This error shows up for EVERY form field in my forms.py (I've commented out one by one). FYI, I'm using Django's development version (0.96-pre), could this be a problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom admin field widgets in the newforms-admin branch
On 6/27/07, leif <[EMAIL PROTECTED]> wrote: > Does anyone have information on this topic? I have a feeling I'm not > the only one who's wondering this. Thanks! Your best bet is probably to read the source right now; when the branch is complete there will undoubtedly be documentation showing the sorts of things you can do with it, but at the moment the code is still under development. -- "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: Custom admin field widgets in the newforms-admin branch
Does anyone have information on this topic? I have a feeling I'm not the only one who's wondering this. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Zip code lookup field
Great advice -- thanks! I'll work on it today and let you know how it comes together. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Re-rendering same page
On 6/27/07, Val <[EMAIL PROTECTED]> wrote: ... >change a boolean > value A boolean value where, in what context, for what purpose? > it > takes multiple refreshes for the value to update itself. There are multiple processes in general-- runserver is one process, but shouldn't be used outside of development. If you're setting a value you wish to be shared amongst multiple requests, you need to put it out of process somehow. Cache or DB are the general answers. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
On 6/27/07, leif <[EMAIL PROTECTED]> wrote: ... > Thanks for the input, Jeremy. I've actually decided to use newforms- > admin since I won't be going to production for another few months Sorry for missing that the first time. :) Admin uses django.newforms.models.form_for_model, which takes an optional formfield_callback in order to map between DB fields and form fields. In order to supply that parameter, it looks like you'll need to inherit from django.contrib.admin.options.ModelAdmin and override formfield_for_dbfield. That method maps between database fields and form fields. Have formfield_for_dbfield return your custom field class (a subclass of django.newforms.fields.Field; CharField might make sense), then override the Field.clean method to do your FK lookup and raise a ValidationError if it's not a valid zip code. NB: I haven't used newforms much myself yet. Please report back if you run into any troubles. :) You'll end up with something like this: class MyAdmin(ModelAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if isinstance(db_field, models.ForeignKey) and db_field.name == 'zip_code': return ZipCodeField(**kwargs) else: super(MyAdmin, self).formfield_for_dbfield(db_field, **kwargs) --- class ZipCodeField(CharField): def __init__(self, *args, **kwargs): self.max_length, self.min_length = 5, 5 super(ZipCodeField, self).__init__(*args, **kwargs) def clean(self, value): value = super(ZipCodeField, self).clean(self, value) from yourmodels import ZipCode try: ZipCode.objects.get(pk=value) except ZipCode.DoesNotExist: raise ValidationError, "Please enter a valid zip code" return value --- from django.contrib.admin import site site.register(YourModel, YourAdminClass) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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-rendering same page
I am having difficulty with re-rendering the same template. My site is designed with links which, when clicked, will change a boolean value (this is done via a query string), then re-render the page they were clicked from. The problem is that when the page is rendered, it takes multiple refreshes for the value to update itself. Is this a problem anyone else has experienced? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 tag render method never called
Hi, I'm using Django 0.91 More or less, this is what I'm doing: appname/templatetags/app_extras.py: from django.core.template import Library, Node register = Library() class MyNode(Node): def __init__(self, foo): self.foo = foo print 'foo' * 100 def render(self, context): print 'bar' * 100 return 'bar' * 100 @register.tag def mytag(parser, token): return MyNode(0) In my template: {% load app_extras %} {% mytag %} When I run this using the development server, 'foo' * 100 is printed, but 'bar' * 100 is not. That is, it looks like render is never being called? Is there anything obviously wrong with what I'm doing? On another note, I tried stepping through the code with pdb, but it was ignoring my breakpoints. I tried running the server with -- noreload too, but 0.91 doesn't seem to support that. Any advice would be greatly appreciated, thanks. Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Method to find the admin url for an object
In going through cleaning up all the hard-coded urls in my templates, I'm making good use of the get_absolute_url methods that I've added to my models. Looking at the links I'm left with, they're almost all to the admin pages. How would I write a method to provide a get_admin_change_url method ? Thanks, Chris Brand --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: generating customized flyers (pngs or pdf)
Its been a while since I used reportlab but shouldn't he be able to add the image and place some text on top of it without generating a whole image with PIL and then placing it in pdf? Of course that assumes pdf output only and not png. I think the best results would be the reportlab route anyway. It has a lot of nice formatting tricks and handles flow very well. Much better than trying to do it yourself on a raw canvas. On Jun 27, 8:10 am, KpoH <[EMAIL PROTECTED]> wrote: > Hello, > use PIL (http://www.pythonware.com/products/pil/) for this > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
RE: test client login problems
> > I'm running into problems with the test client's login method. > > Specifically, within a single test method, the first login succeeds but > the > > second one fails. > > Is this something that should work ? Am I doing something wrong ? > > The 'bool object has no attribute status_code' message is generated > because the login() method visits the named url, and tries to fill in > the form it finds. If you are already logged in, and you visit a > login-decorated view, the login form won't be shown - the underlying > content will be shown. The login() test method returns true because a > user is already logged in. Ahhh. So after I've used login() once in a test, get() will pass the existing session cookie, in which case my test to retrieve two pages while logged in would look like : client.login(...) client.get(...) Does that sound right ? I'll try that later today. > You should also be warned that revision [5152] (post 0.96 release) > modified the login method to use the internal authentication plumbing, > rather than using a login view. This will affect the way you write > your tests using the login method, although you will probably still > experience difficulties if you try to 'double login' like your test > view is trying to do. Yes, I saw that. Thanks for the warning, though. Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
error: (32, 'Broken pipe'), ThreadLocals & ticket #4444
I'm trying to debug a problem for which vanderkerkoff opened ticket http://code.djangoproject.com/ticket/, the fact that under some circumstances the development server prints a tracebak terminating with: error: (32, 'Broken pipe') I noticed that if I add middleware ThreadLocals as per: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser even going to admin page raises that error, even if it does not seem to be any harmfull. Is there somebody, using ThreadLocals that does not have this same problem? I'd appreciate both positive & negative feedbacks thanks sandro *:-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to link to other pages in templates
Try the {% url %} tag: http://www.djangoproject.com/documentation/templates/#url tom On Jun 27, 2007, at 6:33 PM, Ryan K wrote: > > What is the best form of a link in my Django site's templates? For > example, I have a base.html which serves as the base template for all > others. It contains links that are relative to the current directory > like Manage. However, when I am at a page like > http://example.com/mydjangosite/manage/edit/23123 (editing the object > with id 23123) the same link above is instead pointing to > http://example.com/mydjangosite/manage/manage. I constantly have to > deploy this application to the main server but normally I work on it > locally, so absolute links would be a pain. Should I use templated > URLs (e.g. Manage) for my links or > is there a better way? > > Thanks, > Ryan > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Best way to link to other pages in templates
What is the best form of a link in my Django site's templates? For example, I have a base.html which serves as the base template for all others. It contains links that are relative to the current directory like Manage. However, when I am at a page like http://example.com/mydjangosite/manage/edit/23123 (editing the object with id 23123) the same link above is instead pointing to http://example.com/mydjangosite/manage/manage. I constantly have to deploy this application to the main server but normally I work on it locally, so absolute links would be a pain. Should I use templated URLs (e.g. Manage) for my links or is there a better way? Thanks, Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 Attribute Errors
Hi Malcolm, This is my traceback errors from copy: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/www/htdocs/gfs_chefrevival/../gfs_chefrevival/shop/views.py" in vendor 133. new_detail = form.save() AttributeError at /vendor/Chef/1/ 'Order_DetailForm' object has no attribute 'save' --- This is traceback errors from interactive view: 133. new_detail = form.save() Local vars: Variable Value OrderDetailForm cart_id1L form I think it has something to do with how I'm importing. This is my complete import statements: from django.shortcuts import render_to_response, get_object_or_404 from django.contrib import * from gfs_chefrevival.store.models import * from gfs_chefrevival.products.models import * from gfs_chefrevival.vendors.models import Vendor from django.http import * from django.db import models from django import newforms as forms <- import datetime from django.contrib.auth.models import User Hopefully you guys can get more insight to this. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use Django's database layer for a regular python program?
On Wed, Jun 27, 2007 at 04:53:12PM +0200, Roodie wrote: > > I worked on a console application which uses django to do some > database related tasks. > I started my code with these lines: > > --- > > #!/usr/bin/env python > import sys > sys.path.append('/Library/Frameworks/Python.framework/Versions/2.4/ > lib/python2.4/site-packages/django') > sys.path.append('/path/to/the/application/directory/') > > import os > os.environ['DJANGO_SETTINGS_MODULE'] = 'applicationname.settings' > > --- > > From this point you can continue by importing the neccessary > libraries and writing your code. > > Maybe there is a better way of doing it but works perfeclty. Have a look at django.conf.settings.configure: from django.conf import settings settings.configure( INSTALLED_APPS = ( 'myappcontainingmodels', ), DEBUG = False ) See: http://www.djangoproject.com/documentation/settings/#using-settings-without-setting-django-settings-module -Forest signature.asc Description: Digital signature
freecomments not displayed II
(sorry for the bad english) I'm with the same problem of this (closed) thread: http://groups.google.com/group/django-users/browse_thread/thread/9930f6e624fd8363/f52bc916056d7dbd?lnk=gst=free+comments=1#f52bc916056d7dbd Using django-svn. In two local installations (Mac and Ubuntu), freecomments works flawless (with "manage.py runserver"). But at the server of webfaction, they don't show up, though the code is the same. In the admin interface, the sum of comments appears, but the list is empty. I checked at the phpMyAdmin: freecomments are there. Tried drop all tables and syncdb, but it didn't work. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use Django's database layer for a regular python program?
I worked on a console application which uses django to do some database related tasks. I started my code with these lines: --- #!/usr/bin/env python import sys sys.path.append('/Library/Frameworks/Python.framework/Versions/2.4/ lib/python2.4/site-packages/django') sys.path.append('/path/to/the/application/directory/') import os os.environ['DJANGO_SETTINGS_MODULE'] = 'applicationname.settings' --- From this point you can continue by importing the neccessary libraries and writing your code. Maybe there is a better way of doing it but works perfeclty. --- Roodie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
using django.contrib.auth interface
Hi fellows, I have doing a custom user authentication, I have my own views to control login and logout, and works great, but now I wish use the authentication views that Django provides. When forms call to login view, Django authenticate user but then redirect to '/account/profile'. Reading the source code ( django/ contrib/auth/views.py) I realized that there is a vars REDIRECT_FIELD_NAME that is setting to redirect_to. Then I found that REDIRECT_FIELD_NAME has a 'next' inside that I suppose that is the name of the var that I must send inside URL. Well, I put this inside the form, but didn't works :( (in the login template that I have) The question is: How can I pass the "next" vars to login view, without hardcode this view? The logout view are using something similar to that, but is getting as a parameter(next_page). So after logout, returns to a custom page that I pass :) Am using Django 0.95 by the way. Cheers.- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: use Django's database layer for a regular python program?
It's currently being done for a server application, I don't see why it couldn't be used for a desktop application as well? Check out http://www.silverstripesoftware.com/blog/archives/51 and http://code.google.com/p/evennia/ The first is a desktop application that uses Django, I'm just not sure if it's using the database backend or not. The second is a MUD server that uses Django for data storage as well as the web services for MUD management. It should be as simple as creating a new project and ignoring the urls/ views part of the code, and just importing the models as normal. HTH, Michael On Jun 27, 7:09 am, ahlongxp <[EMAIL PROTECTED]> wrote: > I'm currently developing a desktop application, not a web application. > But I want to use django's models to store and retrieve data in > Database. Is it possible? How should I do it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
On 6/27/07, Vance Dubberly <[EMAIL PROTECTED]> wrote: ... > ball of red tape but let's just say django is ALOT more resource intensive > and ALOT slower. Have you done any profiling? I haven't compared such a port, but I'd be surprised if performance is significantly (i.e. one order) different without some optimization being missed. If you have, can you point to any parts of Django that we could improve? As presented, there's not much actionable. "Java is faster than Python" is not news, but I doubt the language is the problem here. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Change date/datetime input string for admin-interface
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hey, how can I change the string for date/datetime fields in the admin interface? 2007-08-15 should be changed to 15.8.2007 ("d.m.Y H:i") Thanks, Manuel -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (Darwin) iQEVAwUBRoJWtDOKNHIOcnYMAQj31ggAuBusrZ7XZnU+ze6vZyWHn1W7u0pVTOir tJYEEb6JZktaV9TBkaG9pe1FK+4IuvA1wavxdfBXWYYRskaMHnc2M29zcbmB/nmw KpNqce6QDFmr6PPmOA0pM7Uq3yfSH3I+900TtFCpGBKKUHizJcTBhtSgBeb/RHK5 LP9bYdlfAISPUNC2eHgGxB+UKArbZylD5WtcDGtTatL1ZXgQbnN+kCBL4rYojI9M EhFngUiE40MXHtX98jaNu2oKVs83dU9qcMcKQizEQCZCpHNC4pF+SLe55e2LdIB5 +NSce7I+bkbSQ0ZSxWGpCMH02z1vS4Ic+MYah1QaJtV5DJa1wUFhTQ== =Wbi3 -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: generating customized flyers (pngs or pdf)
KpoH skrev: > Hello, > use PIL (http://www.pythonware.com/products/pil/) for this > Note the nice logo in the left sidebar :-) 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: generating customized flyers (pngs or pdf)
Hello, use PIL (http://www.pythonware.com/products/pil/) for this ndengler пишет: > hello, > we want to output small flyers that users can print (or could > display). > I had a look at http://www.djangoproject.com/documentation/outputting_pdf/ > which explains how to creat pdfs with templates. > > How can we also create images? > having a personalized text over a background image to be printed? > > Thanks, > Nicolas > mixin - sharing activities with friends > -- Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L. http://www.asterisksupport.ru http://www.asterisk-support.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 -~--~~~~--~~--~--~---
generating customized flyers (pngs or pdf)
hello, we want to output small flyers that users can print (or could display). I had a look at http://www.djangoproject.com/documentation/outputting_pdf/ which explains how to creat pdfs with templates. How can we also create images? having a personalized text over a background image to be printed? Thanks, Nicolas mixin - sharing activities with friends --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: nasa site on django
Hi, > Vance Dubberly wrote: > > On the plus side it is faster than a similar PHP app ( with APC ) and > > faster than serving static files. Afaik, dynamic things _can't be_ faster than static things. 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 -~--~~~~--~~--~--~---
Always free - no trial versions or spyware, Ready to use
Hi, Your best pictures are now on display. Pick a favorite photo as your desktop picture or add several into your screensaver rotation. What better way to enjoy your photographic genius at your desk? Click Below Now www.chulbul.com/picasa.htm Enjoy this small piece of Software... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
use Django's database layer for a regular python program?
I'm currently developing a desktop application, not a web application. But I want to use django's models to store and retrieve data in Database. Is it possible? How should I do it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Password Logistics Help Needed
Long story short, I'm building a control panel + backend to an MMORPG. It runs off of a mySQL database, I used inspectdb, and all of that worked perfectly. However, now I have some duplicate data, the User model (since I'm using django-registration) and the account table of the inspected database. I'm sure I could just assign the applicable values from the User model to the account table while creating the user's profile via profile_callback(), but the only problem I can't seem to get my head around is the password one. At the moment, the game can only read md5 or plain-text passwords, and I know that Django has the hash$salt$hash (or something. :P) way of doing it. So I can't just copy the password from the User model to the account table since the game will choke on that data. So is there any way I can store two sets of the password? One in the user model that gets copied as md5 or plain-text to my accounts table? Thanks in advance, please let me know if I have to explain things a bit more. :) Cheers, Bryan V. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Plat_Forms web development survey
PS: if you are a member of digg or Slashdot and would like to support the survey, here are the relevant articles: http://digg.com/programming/How_does_your_web_development_platform_rate http://slashdot.org/firehose.pl?op=view=205681 Cheers, Will Hardy Plat_forms survey team --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Forms and formating error messages
On Wed, 2007-06-27 at 02:26 -0700, AnaReis wrote: > Hi again, > This is getting very frustrating because I can't make this work... > This is exactly what I wrote in the files: In future, please remember that when you send a message like this, a lot of us are reading it through an e-mail interface, so include the necessary context to help us understand the problem. I ended up having to go back and read all your earlier messages in the thread to work out what the problem is that you were having. People, including me, may not always feel like spending that much time to answer a question, so please help us to help you. If I understand correctly, you want to have control over error message presentaiton. [... snip...] > [field.html] >> > {{ field.label }}{% if > field.field.required %}*{% endif %}: label> > > > {{ field }} > {% if field.errors %}{{ field.errors }}{% endif %} So this is the problem. If you look at field classes (in newforms.fields), you can see that the errors attribute is a newforms.util.ErrorList class and the __str__ method for ErrorList is the as_ul() method -- displaying results as an unordered list. If you want to control the presentation, you will need to iterate over field.errors and write out the results one by one. Or you could write a filter that applies to field.error and does this for you. Remember that ErrorList is a subclass of Python's standard lists, so something like (untested): {% if field.errors %} {% for error in field.errors %} {{ error }} {% endfor %} {% endif %} This particular example would just dump the strings with br tags between them, but you can obviously do whatever you want there. Some experimentation will be required, but since you have full access to the raw error strings, anything should be possible. Regards, Malcolm -- Works better when plugged in. 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: Forms and formating error messages
Hi again, This is getting very frustrating because I can't make this work... This is exactly what I wrote in the files: [newforms.py] from django import newforms as forms from django.newforms.forms import BoundField from django.template import Context, loader class TemplatedForm(forms.Form): def cc(self): "Helper function for fieldsting fields data from form." bound_fields = [BoundField(self, field, name) for name, field \ in self.fields.items()] c = Context(dict(form = self, bound_fields = bound_fields)) t = loader.get_template('newforms/form.html') return t.render(c) def __str__(self): return self.output_via_template() [form.html] {% for field in bound_fields %} {% include "newforms/field.html" %} {% endfor %} [field.html]{{ field.label }}{% if field.field.required %}*{% endif %}: {{ field }} {% if field.errors %}{{ field.errors }}{% endif %} {% if field.help_text %} ({{ field.help_text }}) {% endif %} This probably has to be modified to do what I want it to do (present the error text as simple text and not as ) but I have no idea where I have to change this to do what I want it to do. I know that the changes have to be made on the function output_via_template(), but I just don't know what am I supposed to do there. :( 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 -~--~~~~--~~--~--~---
Problem with URL
Hi, I'm having a problem here and I don't really know how to solve it. I have a form on a page, the add user page: (r'^manager/operations/nlsciadc/users/adduser/$', add_user), #The template is add_user.html When the user presses submit, the action on the form sends the user to: This on my urls.py call the view function result_add: (r'^manager/operations/nlsciadc/users/adduser/resultadd/$', result_add), If an error occurs in the form, for example, the passwords don't match, the user is sent back to the add_user.html template: if not form.is_valid(): return render_to_response('add_user.html', {'form':form}) The problem is that when the user is sent back to the add user page to correct the errors, instead of going to the URL manager/operations/ nlsciadc/users/adduser/ it remains in the URL manager/operations/ nlsciadc/users/adduser/resultadd/ so when the user presses the submit button again the user is sent to the URL /manager/operations/nlsciadc/ users/adduser/resultadd/resultadd/ which obviously isn't mapped on the urls.py file. The only thing I can think of is telling the user to press the back button and fill the form again, but besides this being a lame solution, it's much better for the user to have the filled form with the errors next to each field and just having to correct them, instead of having to go back and fill the form. I don't really know how to fix this. Is there anyway in the view in which I can call an URL in the http response? Anyone has any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: cx_Oracle deploying problem
On Wed, 2007-06-27 at 01:34 -0700, audial wrote: > Hello! > > I've developed my project on my desktop machine ( WinXP + Python > 2.4.4. + Oracle Express Edition ). > Now I have a problem with deploying it on the Gentoo Linux 2007.0 > ( Python 2.4.4 + Oracle 10.2.0.1 ) > I don't see ANY russian chars, there are '?' (question symbols) > instead of them =( You don't mention which code branch you are working with. If you are using trunk, then non-ASCII characters are very difficult to work with in general and not really recommended. That will soon be corrected with the merging of the Unicode branch back into trunk. If you are using the Unicode branch, I have not yet added Unicode support to the Oracle backend. That will be happening during this week sometime, as I work my way through all the details. > Great problem occured after half an year of development work. > I'm not so good in python skilling, I've started from Django on it. > > I have NLS_LANG = RUSSIAN_RUSSIA.CL8KOI8R parameter and also locale = > ru_RU.KOI8R > The DEFAULT_CHARSET is also 'koi8-r' > > I know, that oracle-branch is not so stable On the contrary, the Oracle code has now been merged into trunk and should be very stable, although small bugs may be found over time. Regards, Malcolm -- Tolkien is hobbit-forming. 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 -~--~~~~--~~--~--~---
cx_Oracle deploying problem
Hello! I've developed my project on my desktop machine ( WinXP + Python 2.4.4. + Oracle Express Edition ). Now I have a problem with deploying it on the Gentoo Linux 2007.0 ( Python 2.4.4 + Oracle 10.2.0.1 ) I don't see ANY russian chars, there are '?' (question symbols) instead of them =( Great problem occured after half an year of development work. I'm not so good in python skilling, I've started from Django on it. I have NLS_LANG = RUSSIAN_RUSSIA.CL8KOI8R parameter and also locale = ru_RU.KOI8R The DEFAULT_CHARSET is also 'koi8-r' I know, that oracle-branch is not so stable, but for now i can;t go from it, cause a great part of business logic is stored there with close-relations. Additional database is not a good idea I think. Help, please. Farid Adigamov --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: nasa site on django
I don't understand. Static files served by django? Vance Dubberly wrote: > Moved http://opensource.arc.nasa.gov to django a couple of weeks ago. > Thought ya'll might want to know that. > > Also thought you might want to know the site was running on > Tomcat/Mysql and the performance difference is mind blowing. > Unfortunately the actual server specs and benchmarks can't be released > without going through a nasty ball of red tape but let's just say > django is ALOT more resource intensive and ALOT slower. > > On the plus side it is faster than a similar PHP app ( with APC ) and > faster than serving static files. > > -- > To pretend, I actually do the thing: I have therefore only pretended > to pretend. > - Jacques Derrida -- Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L. http://www.asterisksupport.ru http://www.asterisk-support.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: Unittests and coverage
> The approach here will be to write your own test runner method. When > you call 'manage.py test', Django is effectively calling a method > called django.test.simple.run_tests(); this method sets up the test > environment, finds the tests, runs the tests, and cleans up the test > environment. Thank you very much Russell, it is *exactly* what I need. > However, you can direct django to point at a different method of your > own choosing. Define a method like: > > from django.tests.simple import run_tests Note for other readers. Here is small typo, correct is: from django.test.simple import run_tests Thank you again Russell Regards Michal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
nasa site on django
Moved http://opensource.arc.nasa.gov to django a couple of weeks ago. Thought ya'll might want to know that. Also thought you might want to know the site was running on Tomcat/Mysql and the performance difference is mind blowing. Unfortunately the actual server specs and benchmarks can't be released without going through a nasty ball of red tape but let's just say django is ALOT more resource intensive and ALOT slower. On the plus side it is faster than a similar PHP app ( with APC ) and faster than serving static files. -- To pretend, I actually do the thing: I have therefore only pretended to pretend. - Jacques Derrida --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 can I rename uploaded files to a random filename?
If you just want to upload some files you might do something like the following. The save function uses plain python to save the files to the FILE_UPLOAD_DIR you defined in your setting file. You can play around with the file names as much as you want here. Question: Why a random name? Vincent class Application_files(forms.Form): cv = forms.Field(label = 'CV *', widget = forms.FileInput(), help_text="pdf or Word document") paper = forms.Field(label = 'Paper *', widget = forms.FileInput(), help_text="pdf or Word document") def save(file,key,user,ext,overwrite=True): if ext in ['pdf','doc']: f = open('%s%s_%s.%s' % (settings.FILE_UPLOAD_DIR,key,user,ext,),'wb') f.write(file) f.close() def apply(request): if request.POST: for i in request.FILES.keys(): ext = request.FILES[i]['filename'][-3:].lower() file = request.FILES[i]['content'] save(file,i,request.user,ext.lower()) else: form = Application_files() return render_to_response('apply/apply.html',{'form':form,}) On 6/26/07 10:43 PM, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > > On 6/25/07, rob <[EMAIL PROTECTED]> wrote: >> >> We upload all of our images via the Admin app and would like all >> uploaded images to be renamed to a set of numbers. We can generate the >> random numbers fine, but is there an easy way to rename the file once >> it's uploaded in the Admin app? > > Not at present. You would need to write a customized FileField to > implement this sort of behaviour. > > Yours, > Russ Magee %-) > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Zip code lookup field
> Django's existing admin uses oldforms. The newforms-admin branch is > working to rewrite admin to be more flexible and use newforms. If you > need it on trunk now, you'll need to use oldforms. Thanks for the input, Jeremy. I've actually decided to use newforms- admin since I won't be going to production for another few months (and hopefully it will be incorporated into the trunk soon). Do you know how I can attack the problem using that branch? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---