Re: Query on 2 non related models

2019-05-20 Thread Rafael E. Ferrero
Hello Ivan... you say Unrelated but I see you have a relation with VendorGroup... why don't use a ForeignKey?... any way you can use the pipe charater " | " to concatenate two querysets. https://simpleisbetterthancomplex.com/tips/2016/06/20/django-tip-5-how-to-merge-querysets.html Cheers! Rafae

Query on 2 non related models

2019-05-20 Thread Ivan Martić
Hi guys, hope you can help me. I have 2 models and i want to make a count query on them. I need a count on how many articles i have in every category. Models: class Vendors(models.Model): id = models.AutoField(db_column='id', primary_key=True, blank=False, unique=True) name = models.Cha

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
Please forget about the persisting data part. The problem is that inside the parent form i dont have access to the related data and the formsets new related data is validated after the parent models data. Inside the formset every related data model does not have access to the other related inst

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
I still don't understand why you want to persist unvalidated data to the db then? if a user requests the data in mid-update, that's something that can be handled with transaction locks on the db. so when that happens, the request will wait till the locks are released before executing the db qu

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
Am Sonntag, 26. August 2018 18:29:49 UTC+2 schrieb Jason: > > I think we're missing a few things. how fast does this query with updated > values execute after the form submits? > a neglectable amount of milliseconds > if you need to return the value back to the view, can't you do some sort

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
I think we're missing a few things. how fast does this query with updated values execute after the form submits? if you need to return the value back to the view, can't you do some sort of post-save retrieval and form populate? -- You received this message because you are subscribed to the Go

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
Am Sonntag, 26. August 2018 18:07:25 UTC+2 schrieb Jason: > > why would you want to persist unvalidated data to your db? > >> >> Well, i dont necessarily have to, but i somehow need to be able to perform a query with all updated data taken into account. The easiest solution i came up with is pu

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
why would you want to persist unvalidated data to your db? On Sunday, August 26, 2018 at 10:42:28 AM UTC-4, Andy wrote: > > I want to execute a check after the related data from the admin has been > saved, but the default clean methods get executed before the formsets are > saved. Where could i

How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
I want to execute a check after the related data from the admin has been saved, but the default clean methods get executed before the formsets are saved. Where could i place my check to have access to a full version of what has been changed on the admin page? -- You received this message becau

Re: Same form saving to related models

2017-06-10 Thread Melvyn Sopacua
On Saturday 10 June 2017 15:42:50 Elorm Koku wrote: > Melvin thanks, actually my models are simplified...the switch of fk > was a way of trying to use it at d front end so that I could provide > an id to link em up...unfortunately I can't go around it since an > instance of the model is not easily

Re: Same form saving to related models

2017-06-10 Thread yingi keme
Yea exactly. A many to many relationship is the best approach on this. Elorm you should try many to many relationship if you are not completely satisfied. Thanks Melvyn Yingi Kem > On 10 Jun 2017, at 3:38 PM, Melvyn Sopacua wrote: > > On Saturday 10 June 2017 13:20:11 yingi keme wrote: >

Re: Same form saving to related models

2017-06-10 Thread Elorm Koku
Melvin thanks, actually my models are simplified...the switch of fk was a way of trying to use it at d front end so that I could provide an id to link em up...unfortunately I can't go around it since an instance of the model is not easily accessible cos its a new object not saved yet...I thought of

Re: Same form saving to related models

2017-06-10 Thread Melvyn Sopacua
On Saturday 10 June 2017 13:20:11 yingi keme wrote: > The variable for foreign key is supposed to be declared under Student > model because parents can typically have more than one kid in a > school isnt it? And typically, students can have more then one parent. So either rename your Parent mod

Re: Same form saving to related models

2017-06-10 Thread Elorm Koku
Thanks yingi, u saved a life :) On Jun 10, 2017 12:20 PM, "yingi keme" wrote: > Well. What you are trying to do is a bit awkward, but i will try my best > to answer. > > The variable for foreign key is supposed to be declared under Student > model because parents can typically have more than one

Re: Same form saving to related models

2017-06-10 Thread yingi keme
Well. What you are trying to do is a bit awkward, but i will try my best to answer. The variable for foreign key is supposed to be declared under Student model because parents can typically have more than one kid in a school isnt it? You should try and understand relational database. Now this i

Re: Same form saving to related models

2017-06-09 Thread Elorm Koku
No luck for me? On Jun 9, 2017 4:43 AM, "Elorm Koku" wrote: > Hi guys, > I need a means to save these 2 models related by FK but I want to use one > form. I searched but I jus can't do it. > > class Student(models.Model): > ... > > class Parent(models.Model): > > child = models.Fore

Same form saving to related models

2017-06-08 Thread Elorm Koku
Hi guys, I need a means to save these 2 models related by FK but I want to use one form. I searched but I jus can't do it. class Student(models.Model): ... class Parent(models.Model): child = models.ForeignKey(Student) All I need is a form I can use to every student and their paren

Re: Validating and cleaning related models ...

2017-02-01 Thread Bernd Wechner
Melvyn, Thanks. Alas That was but one example in an apocryphal model set, and I have rather more relationship criteria to test in a more complex nest of models. I'm still drilling down into Django to see what I can uncover. Notably form.instance for the main form and all the related formsets, t

Re: Validating and cleaning related models ...

2017-01-25 Thread Melvyn Sopacua
On Tuesday 24 January 2017 17:50:39 Bernd Wechner wrote: > I find myself in a conundrum with related models and related formsets. > I'll try and simplify a rather complex set of relations to illustrate > the bare bones gist of my issue. Imagine the standard Djnago docs > ex

Validating and cleaning related models ...

2017-01-24 Thread Bernd Wechner
I find myself in a conundrum with related models and related formsets. I'll try and simplify a rather complex set of relations to illustrate the bare bones gist of my issue. Imagine the standard Djnago docs example: class Musician(models.Model): first_name = models.CharField(max_leng

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
Thanks Todor/Constantine for your help, I've added a field in my Product models with generic relations like: hitcounts = GenericRelation(HitCount, content_type_field='content_type', object_id_field='object_pk',) In my view: object_list = Product.objects.order_by('-hitcounts__hits')[:6] In my tem

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
Todor, You have access to my complete repo but still I will post answer here for others to learn. Regards, Mudassar On Fri, Aug 5, 2016 at 6:06 AM, Todor Velichkov wrote: > Honestly, now Idea why you get this error, can you paste some more code? > And maybe some stack trace? > > On Friday, Aug

Re: QuerySet for related models

2016-08-05 Thread Todor Velichkov
Honestly, now Idea why you get this error, can you paste some more code? And maybe some stack trace? On Friday, August 5, 2016 at 2:20:25 PM UTC+3, M Hashmi wrote: > > 1.8.13 as its LTS. > > On Fri, Aug 5, 2016 at 3:54 AM, Todor Velichkov > wrote: > >> Whats your Django version? >> >> On Friday,

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
1.8.13 as its LTS. On Fri, Aug 5, 2016 at 3:54 AM, Todor Velichkov wrote: > Whats your Django version? > > On Friday, August 5, 2016 at 1:42:48 PM UTC+3, M Hashmi wrote: >> >> I did the same thing while working with the contenttype except I did used >> default filters .all(), .filter(), .get(),

Re: QuerySet for related models

2016-08-05 Thread Todor Velichkov
Whats your Django version? On Friday, August 5, 2016 at 1:42:48 PM UTC+3, M Hashmi wrote: > > I did the same thing while working with the contenttype except I did used > default filters .all(), .filter(), .get(), annotations and aggregations > etc. Todor each product shows multiple hits if I log

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
I did the same thing while working with the contenttype except I did used default filters .all(), .filter(), .get(), annotations and aggregations etc. Todor each product shows multiple hits if I log out and hit it and login back to hit it shows more than one hits. Hits are being recoreded for each

Re: QuerySet for related models

2016-08-05 Thread Todor Velichkov
Constantine Covtushenko, HitCount is a model from a 3rd party app, so the OP can't change it. However the way HitCount is implemented I don't think one there is a way for one product to have more than one `HitCount` objects. So I don't think any aggregations are needed. Lets the Product cla

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thanks for reply and I tried this before same exact code but I got stuck at "unhashable type" error. I searched it thoroughly but then I gave up on it to have some guidance from kind people like you. If you believe this is how it should work then please provide me some quick ref for the error.

Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Hi M Hashmi, I believe that you are looking a way to use aggregation on related model. You should try the following snitppet: `trending_products = Product.objects.aggregate(hit=Max('hits__hits'))[:6]` (see more info here ) This will gi

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Hello Todor, I followed your directions and used https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/ for reference but I got stuck at error 'GenericForeignKey' object has not attribute 'get_lookup'. I tried Product.objects.aggregate(Count('hits'))[:6]. In my models.py I got follow

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thank you Constantine, I got this mistake fixed and this was really bad mistake from my side. Now with your proposed scenario I am trying to get it work with "trending_products = Product.objects.all().order_by('hits__hits')[:6]" but still it isn't giving me sort by max hits as I used annotate m

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thanks Todor as this make senseall I need is to get the Hitcount's hits presented as local variable to Product model so in queryset I can set order_by. I will try this and will post results. On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote: > > My field hits=models.Fore

Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Please check my notes below: On Thu, Aug 4, 2016 at 10:42 PM, M Hashmi wrote: > My field hits=models.ForeignKey(Hitcount) means that my Product model has > a related model with multiple fields and all the products in Product model > will have one or more hit records. > Sorry but I do not see ho

Re: QuerySet for related models

2016-08-04 Thread Todor Velichkov
> > My field hits=models.ForeignKey(Hitcount) means that my Product model has > a related model with multiple fields and all the products in Product model > will have one or more hit records. Instance of Product model will save a > hit from end user by session/ip/user etc. Honestly, I don't u

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
My field hits=models.ForeignKey(Hitcount) means that my Product model has a related model with multiple fields and all the products in Product model will have one or more hit records. Instance of Product model will save a hit from end user by session/ip/user etc. -- You received this message

Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Hi M Hashmi, As I see your model scheme built with meaning that 1 record of HitCount relates to many records of Product. And in your queries you try to select all products that relate to 5 topmost HitCounts. Am I correct? Will be waiting for your response. On Thu, Aug 4, 2016 at 6:41 PM, M Has

QuerySet for related models

2016-08-04 Thread M Hashmi
I know that count only can be applied for an IntegerField or FloatField but I've created a ForeignKey to another model which contains hitcounts. Now I need to filter results by max count from related model and I couldn't dot it. models.py: class Product(models.Model): title = models.Ch

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Markus Amalthea Magnuson
I will fetch the actual piece of code and build a small test case out of it, will reply again in this thread when I have some more info. On Thu, Jul 30, 2015 at 6:39 PM, Marc Aymerich wrote: > On Thu, Jul 30, 2015 at 3:38 PM, Markus Amalthea Magnuson > wrote: > > Hey, > > > > I stumbled upon a

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Marc Aymerich
On Thu, Jul 30, 2015 at 3:38 PM, Markus Amalthea Magnuson wrote: > Hey, > > I stumbled upon a piece of code and a comment that says this: > > Deleting a model object that has related objects will only cascade delete > those objects if their models have been imported. > > Is this true? I have not f

Re: Testing related models without saving

2015-07-30 Thread Michael Herrmann
I'm very relieved - thanks Tim! If I can help, please let me know. Best, Michael On 30 July 2015 at 17:56, Tim Graham wrote: > We are working on that solution: > https://github.com/django/django/pull/5060 > > > On Thursday, July 30, 2015 at 7:19:31 AM UTC-4, mic...@herrmann.io wrote: >> >> Hi a

Re: Testing related models without saving

2015-07-30 Thread Tim Graham
We are working on that solution: https://github.com/django/django/pull/5060 On Thursday, July 30, 2015 at 7:19:31 AM UTC-4, mic...@herrmann.io wrote: > > Hi all, > > I've just been bitten by this new "feature" as well. I completely don't > understand this design decision of 1.8. It is very useful

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Tim Graham
No, import of related models shouldn't affect cascade deletion. Please open a bug report with steps to reproduce if that's actually the case. Possibly it could be a bug that's fixed by the app loading refactor in 1.7. On Thursday, July 30, 2015 at 9:38:09 AM UTC-4, Markus Am

Does imports of related models affect cascade deletion?

2015-07-30 Thread Markus Amalthea Magnuson
Hey, I stumbled upon a piece of code and a comment that says this: Deleting a model object that has related objects will only cascade delete those objects if their models have been imported. Is this true? I have not found it in the documentation and would like to add a reference to the code co

Re: Testing related models without saving

2015-07-30 Thread michael
Hi all, I've just been bitten by this new "feature" as well. I completely don't understand this design decision of 1.8. It is very useful to be able to create model classes without having to save them to the database, not just for unit tests but also for experimenting in the shell. The new "fea

Re: Testing related models without saving

2015-07-16 Thread Carl Meyer
Hi Roland, On 07/16/2015 07:46 AM, Roland Swingler wrote: >> i'll just say that Django tests don't favor too much into the "unit" > test spectrum; > > That is what I'm seeing - it is the same with rails out of the box as > well. I guess I'm just curious to know whether: > > a) the 'unit' test en

Ajax CRUD: best practise for related models in one view?

2015-07-16 Thread ThomasTheDjangoFan
Hi guys, I am searching for a best-practise tutorial (or code-example) to show me how to implement a frontend CRUD gui for related models - if possible: Ajax based. *Scenario:* Let's say I have a contact-class. 1 contact can have n adresses. The address is assigned to the contact

Re: Testing related models without saving

2015-07-16 Thread Roland Swingler
> i'll just say that Django tests don't favor too much into the "unit" test spectrum; That is what I'm seeing - it is the same with rails out of the box as well. I guess I'm just curious to know whether: a) the 'unit' test end of the spectrum is feasible if that's what you like b) what is avail

Re: Testing related models without saving

2015-07-16 Thread Javier Guerra Giraldez
On Thu, Jul 16, 2015 at 8:18 AM, Roland Swingler wrote: > I understand that the test db uses a different schema (it's the same in > rails), the point is to be able to run tests isolated from having a database > at all. there are several testing styles, each one with different dogmas. discussions

Re: Testing related models without saving

2015-07-16 Thread Roland Swingler
Hi, Thanks for the link - I'll investigate that further, especially as to whether you can set that dynamically. I understand that the test db uses a different schema (it's the same in rails), the point is to be able to run tests isolated from having a database at all. Thanks, Roland -- You

Re: Testing related models without saving

2015-07-16 Thread Bruno A.
This might help maybe: https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.allow_unsaved_instance_assignment On Thursday, 16 July 2015 12:21:30 UTC+1, Roland Swingler wrote: > > Hi all, > > I've very recently come to to Django from a rails background, and > stru

Re: Testing related models without saving

2015-07-16 Thread Bruno A.
You did not quote your models, but I assume your UserProfileDetails has a OneToOne or ForeignKey relationship with User model. With Django, you generally need to save the related model before adding it to the Foreignkey, as the relationship in UserProfileDetails is using the primary key (called

Testing related models without saving

2015-07-16 Thread Roland Swingler
Hi all, I've very recently come to to Django from a rails background, and struggling to do unit testing of Django models without saving to the database as I'm used to in Rails. Lets say you have 2 linked models, for example User and UserProfileDetails, then in my tests I want to set up the str

django admin fieldsets - adding fields of related models

2014-07-14 Thread luke lukes
I have a model `*Employee*` with a OneToOne relationship with `*User*`. I'm trying to include in the Employee admin some User fields (`*first_name, last_name, username, email*`), in order to edit those fields directly from the Employee Add/Change form, but I still haven't figured out how to do i

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-25 Thread Simon Charette
I assumed the OP wanted to get *all* instances of Item even if they don't have any liked status equals to 'L'. The query you provided will filter out instances of Item with `itemlikestatus__count < 1` instead of returning an annotated value of 0. Le mercredi 25 septembre 2013 04:41:37 UTC-4, Da

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-25 Thread Daniel Roseman
On Tuesday, 24 September 2013 21:58:44 UTC+1, Simon Charette wrote: > Unfortunately the Django ORM's doesn't support conditionnal > aggregates > . > This is true, but completely irrelevant to the OP's question, which doesn't require them. The docume

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Simon Charette
Unfortunately the Django ORM's doesn't support conditionnal aggregates . Le mardi 24 septembre 2013 16:50:51 UTC-4, Victor Hooi a écrit : > > Hi, > > I'm trying to use aggregation to count the number of "likes" on an item. > > The likes for an item are

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Simon Charette
Unfortunately the Django ORM's doesn't support conditionnal aggregates . Le mardi 24 septembre 2013 16:50:51 UTC-4, Victor Hooi a écrit : > > Hi, > > I'm trying to use aggregation to count the number of "likes" on an item. > > The likes for an item are

Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Victor Hooi
Hi, I'm trying to use aggregation to count the number of "likes" on an item. The likes for an item are stored in a related model, called LikeStatus: class Item(models.Model): > ... > class ItemLikeStatus(models.Model): > LIKE_STATUS_CHOICES = ( > ('L', 'Liked'), > ('U', 'Unli

Overriding the formset save method/ Inlineformsets with 2 related Models

2013-07-20 Thread Clement Poh
I have a bunch of inline formsets, which are related to two models. In this case I want to have a bunch of "Dealings" associated with a "Report" and a "Question". So I can associate them to one fairly easily. DealingFormset = inlineformset_factory(Report, Dealing, form = DealingForm) So to as

Re: Dynamic forms and related models.

2013-05-09 Thread Andre Terra
On Wed, May 8, 2013 at 6:43 PM, noodlygod wrote: > > > < > Class Level (Text field)> > Definition.objects.filter(category__label='Skill'))> field)> > Definition.objects.filter(category__label=Attribute'))>< Attribute score > (Text field)> > > I was on my way to creating a fully custom form in

Dynamic forms and related models.

2013-05-08 Thread noodlygod
Hello all, I'm attempting to create an RPG character generator using Django. My models are as follows: from django.db import models class Character(models.Model): name = models.CharField(null=False, blank=False, max_length=60) age = models.IntegerField() height = models.CharField(nul

Re: Performance when retrieving data from related models

2013-03-19 Thread Taras D
Thanks again! On 19 March 2013 13:09, Peter of the Norse wrote: > [snip] > > We might put the onus on the client to call: > qs = getTendersForContractor(contractor) > for tender in list(qs.prefetch_related('project', 'project__contract', > 'project__contract')): > print tender, tender.getTot

Re: Performance when retrieving data from related models

2013-03-18 Thread Peter of the Norse
More inline stuff. On Mar 18, 2013, at 4:14 AM, Taras D wrote: > Hi Peter > > On 18 March 2013 16:35, Peter of the Norse wrote: > You’re over thinking this by a large margin. getTendersForContractor should > return a QuerySet. That way you can add things like .select_related as > necessary i

Re: Performance when retrieving data from related models

2013-03-18 Thread Taras D
Hi Peter On 18 March 2013 16:35, Peter of the Norse wrote: > You’re over thinking this by a large margin. getTendersForContractor > should return a QuerySet. That way you can add things like .select_related > as necessary in the view. > > Also, I’m a bit worried about the fact you have a functio

Re: Performance when retrieving data from related models

2013-03-17 Thread Peter of the Norse
You’re over thinking this by a large margin. getTendersForContractor should return a QuerySet. That way you can add things like .select_related as necessary in the view. Also, I’m a bit worried about the fact you have a function called getTendersForContractor. It really should be Tender.object

Performance when retrieving data from related models

2013-03-15 Thread Taras_96
My web app hits the database up to 3k per page because it has to retrieve data from lots of related models. It has a fairly normalised database with a structure similar to: - one project has many contracts - one project has many tenders (a tender is put forward by a contractor) - one contract

Re: Edit two related models on one form

2012-10-06 Thread Fred Stluka
Felix, I'm new to Python and Django, so others may be able to improve on this, but I had a similar scenario recently and this was my solution. I used 2 ModelForms in the same HTML template. My view method looks something like (edited to use your question/answer instead of my original donor/dona

Edit two related models on one form

2012-10-06 Thread Felix Schlitter
Hello, I have a pretty basic problem that I cannot find any reference for to solve. Let's say I have the following relationship scenario: *question *and *answer*, where *each* *question* may have up to *four answers*, but *each* *answer* can only have *one question*. I concluded to put a *Forei

Adding calculated field depending on admin form and inlines/related models

2011-10-06 Thread graeme
from related models that are Inlines in the admin. I cannot get the values from the related models in the form, so I cannot see how to do the calculation there. I cannot find a signal, or another way, of doing the calculation after all the related models have been saved. I could call it using

Re: Calculated value that depends in related models

2011-09-19 Thread graeme
; > I want to save a calculated value to a model field. The calculation > > takes a few seconds and I need to query by it, so I think the > > denormalisation is justified. > > > The problem is that the calculation requires data from two related > > models: one of whi

Re: Calculated value that depends in related models

2011-09-19 Thread Andre Terra
ation > takes a few seconds and I need to query by it, so I think the > denormalisation is justified. > > The problem is that the calculation requires data from two related > models: one of which is the "through" model of a ManyToMany > relationship, the other of wh

Calculated value that depends in related models

2011-09-19 Thread graeme
I want to save a calculated value to a model field. The calculation takes a few seconds and I need to query by it, so I think the denormalisation is justified. The problem is that the calculation requires data from two related models: one of which is the "through" model of a

Query on inherited (related) models broken??

2011-04-14 Thread robim42
Hi guys, I used model inheritance quite a while and came across a problem which I can resolve and actually think is might be a bug in django itself. Because of the size of the project I'm working on it would be a waste of space using the original models here ... so I simplified the classes to repr

Re: Nested iteration through related models

2010-12-22 Thread Tom Evans
On Tue, Dec 21, 2010 at 9:48 PM, Dopster wrote: > Let's say I have the following models: > > class Group(models.Model): >     group_name = models.CharField(max_length=20) > > class Person(models.Model): >     group = models.ForeignKey(Group) >     name = models.CharField(max_length=50) > > How do

Re: Nested iteration through related models

2010-12-21 Thread Javier Guerra Giraldez
in the view: persons = Person.objects.all().order_by('group') in the template: {% for p in persons %} {% ifchanged p.group %} {{p.group}}: {%endifchanged%} {{p.name}} {% endfor %} -- Javier -- You received this message because you are subscribed to the Google Groups "Django users

Nested iteration through related models

2010-12-21 Thread Dopster
Let's say I have the following models: class Group(models.Model): group_name = models.CharField(max_length=20) class Person(models.Model): group = models.ForeignKey(Group) name = models.CharField(max_length=50) How do I get an output of the following? GroupA: John, Stacy, Pete Group

Re: Forms in a Workflow for Related Models

2010-10-29 Thread Miguel Araujo
Hi, You will need to go step by step. First you ask the user for the reviewer with a form. Then the user has to submit the form. You manage your input form and see if the data for that reviewer already exists, if it does, then you load initial data in the second form. Now you redirect the user to

Forms in a Workflow for Related Models

2010-10-28 Thread ghachey
Hi, I think I have a particular case. I could not find an easy way to do this going carefully through all the documentation. I also couldn't find anything close enough in these archives to help me out with my limited experience so I am resorting to asking you. I have a Paper model which records

Inline editing of related models in tree-like fashion

2010-10-07 Thread Neo
I'm stuck with the inline Tree-like-eiditing of related models on same page. I've got three models, A, B and C. Class A Class B fb = foreignkey(A) Class C fc = foreignkey(B) In admin.py I'm doing something like AdminA inlines = [inlin

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
It kind of does... I'll see if I can manage it that way. Thanks again! On Sep 15, 12:13 pm, "nick.l...@gmail.com" wrote: > good luck! :) > > Here's another option... > create a method or function that spawns a new project based off of what ever > project is currenlty being viewed... > > The way

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
good luck! :) Here's another option... create a method or function that spawns a new project based off of what ever project is currenlty being viewed... The way I see it is: Adding a button to the admin that creates a new project based off the one currently being viewed...and then also redirects

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
Again my problem is that i want the actual values of the fields to cascade down into child models, unless overridden by the child models. Thanks again for your help, I'll think this through a bit more, there might be a better way to conceptualize my models and their inheritance than the way Im thi

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
well...when you say inheritance...I was thinking that you were going to create some models like this: class BaseProject(models.Model): title = models.CharField() field2 = models.IntegerField() field3 = models.TextField() class SubProject(BaseProject) """ inherits the fields fr

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
Mmmm seems like inheritance is not as straight forward as I thought it was... Might be that this is the case that the admin doesnt cut it for what I need it to do... Ill probably need to see ways in which I can extend it. Like for example, I can think of adding a callback to the FK selection button

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
Good question! :) I don't know...like I said I hadn't thought it through! :) I'll ponder it a bit... maybe you'd have to tackle it in a different direction...Say something like this: you have a dropdown in your project model that's blankable/nullable and it would essentially be a FK to other pro

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
Im not sure Im getting this properly. In the example above, how would you know what the word "whatever", the query value, stands for? How could you keep it dynamic in that the values of that field is taken from whatever the actual parent object is? Thanks. On Sep 14, 2:34 pm, pixelcowboy wrote:

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
I'll try when I get home, but thanks again for your help! On Sep 14, 11:31 am, "nick.l...@gmail.com" wrote: > Hi again! :) > > I haven't thought this idea through, and very well could be > wildly inefficient! :) > > Though in your admin.py when registering the admin model do something like > this

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread nick.l...@gmail.com
Hi again! :) I haven't thought this idea through, and very well could be wildly inefficient! :) Though in your admin.py when registering the admin model do something like this: from myproject.myapp.models import MyModel, OtherModel class MyModelAdmin(models.admin): object_i_want = OtherMod

Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
Hi, I want a project structure that is as follows: I have an application with project model that has a subproject, and that subproject has other subproject,etc. What I want to get is that the subproject gets the same attributes that the parent project, but is also able to override their values in

Using related models as list-filters in admin

2010-07-05 Thread step
I'm using Photologue 3 (/w Image Kit) and am trying to use a related model as a list-filter in modeladmin. Basically Gallery has a m2m relation to Photo, in the Photo modeladmin I want to be able to sort the images by their related galleries I'm totally stuck. Example from modals.py class G

Re: Django admin - Edit parent model and related models on the same page

2010-06-29 Thread derek
On Jun 28, 1:48 am, DoubleD wrote: > I want to be able to edit all data on one page. How can i achieve > this ? Should i modify my models? If so, then how should i modify > them? > > class TextStyle(models.Model): >     color = models.CharField(_("color"), max_length=7) >     style = models.CharFi

Django admin - Edit parent model and related models on the same page

2010-06-27 Thread DoubleD
I want to be able to edit all data on one page. How can i achieve this ? Should i modify my models? If so, then how should i modify them? class TextStyle(models.Model): color = models.CharField(_("color"), max_length=7) style = models.CharField(_("style"), max_length=30) typeface = m

piston and related models

2010-05-28 Thread Alexandre González
networking_profile.save() return networking_profile And this, my related models: class NetworkingProfile(models.Model): user = models.ForeignKey(User, unique=False) searching = models.TextField(blank=False, help_text='Little description about what are you searching for.

Django query with related models

2010-03-10 Thread aurphir
For the below models: class Customer(models.Model): id = models.IntegerField(primary_key=True) class OrderA(models.Model): name = models.CharField(max_length=20) foo = models.FloatField() customer = models.ForeignKey(Customer) type = models.IntegerField() class OrderB(models.

Re: ordering by fields in related models with Generic Relations

2010-02-17 Thread amenasse
llo, I have a Tag model which has a Generic Foreign Key . I want to order a query on the Tag model by fields in related models (related via the Generic Foreign Key), for Example: >>> [ o.content_object for o in Tag.objects.order_by(&

ordering by fields in related models with Generic Relations

2010-02-17 Thread sysantmin
Hello, I have a Tag model which has a Generic Foreign Key . I want to order a query on the Tag model by fields in related models (related via the Generic Foreign Key), for Example: >>> [ o.content_object for o in >>> Tag.objects.order_by('content_type__id','

Re: order_by related models

2009-11-17 Thread dave.l
Hi Karen, Thank you! I was just being blind -- I'd looked at that paragraph and the double underscore just went in one eye and out the other and didn't register as being different to the old format... doh. -- You received this message because you are subscribed to the Google Groups "Django us

Re: order_by related models

2009-11-16 Thread Karen Tracey
t; the first ordering term on principal_name is no longer working. by > looking at ...query.as_sql() I can see the ORDER BY is not being > added. > > According to the docs: > > New in Django 1.0: Please, see the release notes > > The syntax for ordering across rela

order_by related models

2009-11-16 Thread dave.l
y.as_sql() I can see the ORDER BY is not being added. According to the docs: New in Django 1.0: Please, see the release notes The syntax for ordering across related models has changed. See the Django 0.96 documentation for the old behaviour. but I cannot find any reference to the new synt

Re: displaying fields from 2 related models

2009-10-13 Thread grimmus
It's so simple, thanks alot for the speedy replies ! On Oct 13, 4:31 pm, Héctor García wrote: > Once you have passed your links queryset to the template context, you > can just do: > > {% for saved_link in links %} >     {{ saved_link.link.title }} >     {{ saved_link.link.pub_date }} > {% endfo

  1   2   >