Re: ManyToMany lookups

2009-10-20 Thread r_f_d
Why not do this: for p in products.objects.all(): for c in p.categories.all(): print p,' - ', c -richard On Oct 20, 7:57 am, Михаил Лукин wrote: > As I know, each category has attribute product_set > > 2009/10/20 ausi1972 > > > > > > > I am trying to work out how to construct a q

Passing view extra info from urls.py

2010-09-02 Thread r_f_d
I have looked at the django documentation and searched the group archive for my answer, and believe I know how this is supposed to work, I just cannot figure out why it is not working for me. I want to pass an extra keyword parameter to my view that contains a filter value, but it is not getting p

Re: Reverse Query Name Clash?

2010-11-04 Thread r_f_d
This is actually pretty well documented in the django docs. I suggest you look there for a complete explanation, but briefly: with your model definition, the way you would access a minister's church would be: person_object.church and the way you would access the church a person attends would also

return html snippet via XHR with simplejson

2007-08-10 Thread r_f_d
I was wondering what people are doing to format html snippets returned via XHR. I am currently using code like: response_dict = {} t = ModelObject.objects.all() html_table = render_to_response('table_template.html', {'table': t}) response_dict.update({'table': html_table}) return HttpRespon

Re: How to make a field that can be inserted but not updated?

2007-08-10 Thread r_f_d
If I am not mistaken, editable=False is only applicable to the admin- forms. Simply create a view that checks to see if the user is a superuser and then give them a form to add an email address. peace, -r On Aug 10, 7:59 pm, Russell Blau <[EMAIL PROTECTED]> wrote: > I am working on an applicati

Re: Saving a copy of a model

2007-08-10 Thread r_f_d
I am not sure I understand, I think you want to archive a model instance? or put another way, when the model is no longer active or useful to the user, you would essentially like to treat that database record differently than other records. In that case, you could simply change the archived field

Re: Saving a copy of a model

2007-08-10 Thread r_f_d
you have been playing with and learning about manipulators for a few hours now, if you are new to Django, you may want to avoid using Manipulators as the newforms will be replacing them, if not before, in Version 1. -richard On Aug 10, 10:18 pm, r_f_d <[EMAIL PROTECTED]> wrote: > I am n

Re: How to make a field that can be inserted but not updated?

2007-08-10 Thread r_f_d
ensure that the email address could not be changed, and that the user associated with the email address could not be changed without using a custom view that was limited to the super user. hth, -r On Aug 10, 9:48 pm, r_f_d <[EMAIL PROTECTED]> wrote: > If I am not mistaken, editable=Fals

Re: Need some advice in new project

2007-08-11 Thread r_f_d
I am not sure why you would want "all companies bank accounts in different tables." Is it for security? to ensure that only appropriate people are able to view the records of any given company? There is the row-level-permissions branch, but I do not believe it has been maintained in a while so I

Re: Using queryset values() spanning relationships

2007-08-14 Thread r_f_d
You should be able to do this: p = Publisher.objects.get(pk=1) authors = Author.objects.filter(book__publisher__exact = p).distinct() list = ([(a.id, a.name) for a in authors]) I don't have a python shell handy so I do not know for sure that the syntax is correct, but I do things like this all

Re: insert or update

2007-08-21 Thread r_f_d
As far as insert or update, just overide the save method within the class. It is something that must be done for each class, but what I have done (for essentially the same purpose) is override save() on each model I need to log the action for like so: def save(): # if id exists, this record

Re: Flexible Models?

2007-08-24 Thread r_f_d
I will not say that it is pretty, but, I looked into doing this a while ago for an app I am developing. I wanted to create a system that could inventory and track many different types of assets, and allow for users to essentially create additional asset types on the fly. Essentially, I decided u

Re: Anonymous Users

2007-08-27 Thread r_f_d
I am not sure what exactly you want to model in regard to an 'anonymous' user. By definition, these would be users of an application that nothing is required to be known about and can only access information that is provided by views that do not require authenticated users. Generally, if you wan

Re: second query question

2007-08-28 Thread r_f_d
I believe it would be: Thing.objects.all().exclude(property__property_type__exact = type).distinct() -rfd On Aug 28, 12:24 pm, James Tauber <[EMAIL PROTECTED]> wrote: > There's another query I want to do that I can't seem to wrap my head > around at the moment: > > Say I have a model where Thin

data manipulation in templates or views?

2007-09-07 Thread r_f_d
I have been looking at many of the posts in here in recent weeks and wanted to ask any djangurus out there a question to clear up some confusion I have. Should I do data manipulation in my views or in templates. After reading much of the django documentation and working with the framework for th

Re: Model Blues - A Newbie's question

2008-02-04 Thread r_f_d
Sure, you can do it, with two (at least) ways, one is to put this into your model so it automatically happens, search the documentation or users group for threadlocals middleware. The other way is to simply put it into your view as all views get the request, request.user will provide you with wha

Re: first naive question for a new fresh Django user

2007-09-11 Thread r_f_d
Using the code listed (return render_to_response) is going to cause a page refresh (a synchronous operation), if you are trying to use ajax (asynchronously), you should stick the html from the form and the entry into a json or xml object to return to your javascript callback. This is assuming

Re: Having Django iterate through JSON possible?

2007-09-14 Thread r_f_d
The big issue here would be why to do that. If you are doing this synchronously, why put the data into a json object. Just pass a dictionary and do what yo will. If you are doing this ansynchronously (ala AJAX) then the page will not reload and the template will already be compiled and unable t

Re: Using a filter with many to many relationship

2007-09-14 Thread r_f_d
You are missing Q. try from django.db.models import Q (I think that is where it resides but cannot verify right now, a quick check of the documentation should confirm) Offer.objects.filter(Q(terms__exact = 'term1') & Q(terms__exact = 'term2') & Q(terms__exact = 'term3)) On Sep 14, 6:46 pm, Me

Re: Setting "blank" to one Field?

2007-09-14 Thread r_f_d
I am not sure this is possible, null=True is for the database, while blank=True is for form validation. Also there is a datatype None, there is no datatype blank. If you tried to assign blank as apposed to 'blank' to any variable within python it would complain. If there were not a named variabl

Re: how to link to previous and next objects in object_detail view ?

2007-09-15 Thread r_f_d
I have not tried it with django, so I cannot guarantee this will work, however if I understand what you are attempting I was showing an model instance in a view and needed to get the next one by pk I would probably do: model.objects.filter(pk > current_model_instance_id).order_by(id)[:1] which

Re: two questions about data model

2007-09-15 Thread r_f_d
for the charfield there is a max_length, but for what you are trying to do, you need to set this in the form widget. Take a look at newforms documentation but to point you in the right direction you need to do something like: where f is your form f.base_fields['FIELDNAME'].widget.attrs = {'size'

Re: how to link to previous and next objects in object_detail view ?

2007-09-15 Thread r_f_d
> that the list can be arbitrary. i need to get the previous and the > next items from the list and django does not give me anything in the > template context but the object itself. > > konstantin > > On Sep 15, 6:23 pm, r_f_d <[EMAIL PROTECTED]> wrote: > > > I hav

Re: how to link to previous and next objects in object_detail view ?

2007-09-15 Thread r_f_d
are you using django Generic Views or are you using the word to imply non-special views (i.e. you have a number of views just like this.) -richard On Sep 15, 6:38 pm, akonsu <[EMAIL PROTECTED]> wrote: > his is my understanding of the problem: > > there are two genric views: list view and detail

Re: how to link to previous and next objects in object_detail view ?

2007-09-15 Thread r_f_d
oject.com/documentation/generic_views/#django-view... > > konstantin > > On Sep 15, 8:06 pm, r_f_d <[EMAIL PROTECTED]> wrote: > > > are you using django Generic Views or are you using the word to imply > > non-special views (i.e. you have a number of views just l

Re: Using a filter with many to many relationship

2007-09-16 Thread r_f_d
CTED]> wrote: > I can't get this to work for me. > > For example, I have two records which both share the term 'ThemePark", > one of these records also has the additional term "London". > However, when I run your suggestion I get an empty query set.

Newforms validation question

2007-09-24 Thread r_f_d
I have an app that uses a roll-my-own role-based access system to restrict access to various model instances. Essentially what happens is that there is a role or roles assigned to users that allow them to either view or edit various asset types based on the owning organization. Many of the asset

Re: about auth

2007-09-28 Thread r_f_d
Cat, I will be posting what I am doing within the next day or to for you. -richard On Sep 27, 8:47 pm, Cat <[EMAIL PROTECTED]> wrote: > Richard > > I am currently developing an interface that will need to use role > based row level permissions and would be greatful for anything that > you are wi