Re: show_all_rows = False returns db error message
Try updating to the latest revision, there was a bug I fixed a few days ago that was causing this error for a lot of people. If it still doesn't work, please pastebin your model, and let us know the database system you are using and the steps taken. 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 -~--~~~~--~~--~--~---
Re: Django Cheat Sheet - Lost?
Search on google gave: http://www.woodpecker.org.cn:9081/classes/050925-CPUG/django_reference_sheet.pdf#search=%22django%20reference%20sheet%22 http://code.djangoproject.com/wiki/DjangoCheatSheet 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 -~--~~~~--~~--~--~---
Re: Advanced Admin Customization
Either that, or use a custom manipulator and override the save method there. Depends on if the processing will always need to be done when saving or just done with the form data. If it's the form data, probably best to put it in a manipulator. If you want, just create a manipulator and override it in the model, and only override the save method of the manipulator, the rest can probably be normal. 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 -~--~~~~--~~--~--~---
Re: django/core/meta
See: http://www.djangoproject.com/documentation/model_api/#unique-together Cheers, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advanced Admin Customization
> Oh, I see where you're going with it. Just hide the interface from the > user. That's a great idea, I still need a way though to enforce it so > that carefully crafted POST requests don't allow unauthorized users > from breaking things. That's true, maybe using the custom manipulator would handle that, but I'm not so sure. Possible a combination of the two methods would work, either save and template or manipulator and template. Either method works, more just style then anything else. > > That was my first pass. I subclassed models.IntegerField and overroad > get_manipulator_field_objs, and return my custom Form. However, when > running syncdb I still got a KeyError. > > I think that there is a dict somewhere that maps models to their sql > implementation and that my model doesn't exist in that dict, hence a > KeyError. But that's really just a guess. I'd love to hear from an > authority about where the sql structure of a model is defined. When I get a moment later this evening, I'll dive into the DB code and see what else I can find. From the top of my head, I don't think there is anything, but I might be wrong...when I've been exploring the DB code I haven't looked for anything along those lines. Maybe pastebin the code and the trace and I can offer some more help. 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 -~--~~~~--~~--~--~---
Re: Advanced Admin Customization
> Thanks, that's a neat trick, though from the surface I'm not 100% sure > it will do what I'm thinking. I'll have to investigate further. My > intuition tells me I need to do the checks in the model, maybe with a > save hook, not in the template; but I may be off on that. Maybe, but if you do it in the template then it won't even show the option to the user and you'll avoid the trouble of getting the error from the save method to be displayed to the user. > > I am currently trying option 2, which is not as difficult as I thought > it might be, thought I have gotten stuck. > > I've created a new field that subclasses models.Field, and a new form > that subclasses forms.formField, both seem correct (at lest the models > doesn't throw any errors when starting the server), however when I try > manage.py syncdb appname, the manager errors: KeyError: "MyBitField" > > Does any one know where you include that code does the db creation > stuff? > If all you're using is an Integer, then I'd suggest just subclass the integer field and leave most of it the same as it is and only override the part where it returns the form field. Should avoid a lot of trouble. Cheers, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advanced Admin Customization
Howdy, For the permission checking, you could override the admin template and add auth checking in there for the various permissions you want to check for. See: http://code.djangoproject.com/wiki/ExtendingAdminTemplates for more details on this. And in the auth documents there is info on how to access permissions in the templates. As for the second part, there are two possible routes off the top of my head. Neither of which I have tried or have any idea if they will work, maybe someone else can validate these. From experience, they both should work. 1) Override the default change/add manipulator for the model. E.g. Class Object(Models): ChangeManipulator = NewAddManipulator Therefore you can select the fields you want and how you want them. Including any processing of the data. I guess you could also do the permission checking for fields here, but it might not be the best spot. 2) Create a new field in the model that replaces the integer field you are currently using, in this new field you can override the method get_manipulator_field_objs to return the field object you want for this. See django.db.models.fields for the existing fields. Hope that helps, 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 -~--~~~~--~~--~--~---
Re: AJAXWidgetComboBox in admin?
Nothing right now. Currently the admin interface doesn't use any AJAX, but it has been under discussion for a while to implement it. If you did wish to use it, you could probably modify the admin interface fairly easily to implement it (w/o changing the actual django.contrib.admin) package. There are other threads and articles on the wiki about doing this, but feel free to ask if they don't help. 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 -~--~~~~--~~--~--~---
Re: iteration of object_list in generic detail view
You can do something like this: def extra_object_detail(...): context = {"next":nextObj, "previous":previousObj} return object_detail(..., extra_context=context) The generic view adds the extra_context parameter to the context so you can access it in your template. 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 -~--~~~~--~~--~--~---
Re: Dynamic Menus...
Using javascript would be the way to go. Though you have two options on how to know which car relates to which manufacturer. 1) AJAX: Query the server, which will return a list to be placed in the select field. 2) Hard coded JS: Hard code it into a JS array that will then be used to look up the fields and put it into the select box. If you go this route, you can put the JS into
Re: Problem getting list from SelectMultipleField
Try: data.getlist('teams') 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 -~--~~~~--~~--~--~---
Re: How to check if a request was a POST or GET
Might be of help: http://www.djangoproject.com/documentation/request_response/#httprequest-objects if request.method == 'GET': do_something() elif request.method == 'POST': do_something_else() 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 -~--~~~~--~~--~--~---
Re: returning related field as part of __str__() method?
Try either: def __str__(self): return '%s - %s' % (self.name, str(self.category)) or def __str__(self): return '%s - %s' % (self.name, self.category.name) The problem is that it is using __repr__ to print it out, not str. To force str you have to use the str(). Or you can override the __repr__ method, I suggest using the str() method, __repr__ should be used more as a debug tool rather then representing the object w/ more debug output then str does. 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 -~--~~~~--~~--~--~---
Re: Paging admin pages
This might be of use: http://www.djangoproject.com/documentation/model_api/#list-per-page 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 -~--~~~~--~~--~--~---
Re: how to assign permissions to users and groups?
To add permissions. For user: user.user_permissions.add(perm) (I think, don't have the chance to double check) For group: group.permissions.add(perm) For your question, the permission table contains the codename, verbose name and content type of the object. In most cases, you could probably get away without having the contenttype, but it might be a good idea to put in there if you the permission is only to be used with that specific model. So both are right, just depends on how you want to use the permission. Also, probably a good idea to have the codename of the form: app_name.code_name, it's the format used for the default permissions and might make your life easier to keep it in the same format. 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 -~--~~~~--~~--~--~---
Re: how to assign permissions to users and groups?
If I have a group instance called students and I wanted to add it to the user instance bill I would use: bill.groups.add(students) If you want to have a permission for a view, you will have to use the has_perm method that is within the user model (user.has_perm) and check for the permission you want at the beginning of the view. E.g.: def view_students(request): if not request.user.has_perm("university.view_students"): raise PermissionDenied 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 -~--~~~~--~~--~--~---
Re: Efficient ways to limit_choices_to
Hey Seemant, Sorry about not getting back to you sooner to work on this. Been finishing off last minute details with my SoC project. Here is what I've come up w/ that (w/ my limited testing) seems to work: preacher = models.ForeignKey ( Person, limit_choices_to = { 'role__pk': Role.objects.get(name='Pastor').id} ) Might want to put that into a method that has a try and except for the DoesNotExist exception to handle it. Otherwise, it looks like django may not show the page if the exception is caused. Hope that helps. Chris (aka clong) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Override value on save in admin
Might be of help: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser 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 -~--~~~~--~~--~--~---
Re: how to redirect to a new page,but keep the browser's url unchanged
If you had two views: def view_1(request): return render_to_response(...) def view_2(request): return view_1(request) Will return the view_1 but will be under the view_2 URL. 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 -~--~~~~--~~--~--~---
Re: More complex QuerySets and generic views
You could simplify your urls.py by extending the generic view with another view, e.g. an example from the authorization document: from django.views.generic.date_based import object_detail @login_required def limited_object_detail(*args, **kwargs): return object_detail(*args, **kwargs) It might also help with the problem you are having. 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 -~--~~~~--~~--~--~---
Re: How would I do this with Djangol?
This might help: http://www.djangoproject.com/documentation/db_api/#latest-field-name-none 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 -~--~~~~--~~--~--~---
Re: Creating User Accounts
I believe there are articles on blogs and wiki posts about extending the user model. The basic idea as of right now (as far as I know), before model inheritance is committed, is to connect the two using a foreign key. If you want to create a user and relate it to the customer object, best spot may either be in a custom manipulator or override the save method and create the user then relate it to the customer model and save the customer 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 -~--~~~~--~~--~--~---
Re: Using form manipulator for data in multiple models
Not sure if this is of any help Create a manipulator with the form fields, doesn't matter if they are for two different models just make sure to remember the name. If you want to prepopulate the fields, you might have to fill in the data dictionary before creating the formwrapper and passing the dictionary to the formwrapper. You will have to override the save method in the manipulator and pull the data from the data dictionary and create the separate objects the same as normal. It's probably not the greatest way of doing things, but I'm not sure if there are any generic methods to do similiar 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 -~--~~~~--~~--~--~---
Re: Is AJAX Alone Reason to Use TG?`
It's not very hard to integrate AJAX into Django, it is a bit more manual then TG (from what I've read). But with the AJAX frameworks out there, writing the javascript is far from hard. James has a blog article on AJAX and Django: http://www.b-list.org/weblog/2006/07/31/django-tips-simple-ajax-example-part-1 As well, the wiki has some AJAX snippets and examples. 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 -~--~~~~--~~--~--~---