Migrating from ManyToOne (ForeignKey) into OneToOne in django codebase

2023-03-06 Thread Ngoc Dung Hoang
o part below. The django part is what I would love look for opinions. - I can keep the models as it is and enforce some convention rule/supporting method to have usage of one-to-one relationship. This seem to be ugly and we tent to live with the legacy records for quite some times. - Extend the f

Re: User model as ForeignKey forcing username instead of id.

2022-11-23 Thread Erik Manuel Herazo Jimenez
leted all migrations. > > While I am not positive, I am pretty sure the issue originated due to > updating the original CharField to be the ForeignKey, Django in its > infinite wisdom (not sarcastic) was finding the first non integer in the > instance to assign to the foreignkey. >

Re: User model as ForeignKey forcing username instead of id.

2022-11-23 Thread Blaine Wimberly
Issue resolved. In pure frustration, I dumped the database and deleted all migrations. While I am not positive, I am pretty sure the issue originated due to updating the original CharField to be the ForeignKey, Django in its infinite wisdom (not sarcastic) was finding the first non integer in

User model as ForeignKey forcing username instead of id.

2022-11-23 Thread Blaine Wimberly
instance = username instance.username = (no result) With the above use in a custom signal function I am able to create an entry in my profile table and populate p_username = instance and p_user_id=instance.id. In the above use, I can have p_username as a foreignkey to User, however

Proxy Models in ForeignKey field

2022-10-14 Thread Ayush Bisht
Hey everyone, I need a help, regarding use of proxy models at foreignKey field. class User(AbstractUser): is_customer = models.BooleanField(default=False) ... class Customer(User): objects = CustomerManger() # get_queryset will filtered out all the models based on

Re: ForeignKey Reverse Relation Fail

2022-07-31 Thread Ammar Mohammed
Using many to many relationship will work better. Nice note 🤗 Your quote Translation : "لا يؤمن احدكم حتي يحب لاخيه ما يحب لنفسه" On 27 Jul 2022 19:04, "Malik Rumi" wrote: > Thanks, but the recursive foreignkey *is* a one to many relationship... > unless you'

Re: ForeignKey Reverse Relation Fail

2022-07-31 Thread Ryan Nowakowski
Since this is a question about your models, please post your models.py. On 7/27/22 5:18 AM, Malik Rumi wrote: I have a model with a recursive foreign key to 'self'. This is intended to model a parent child relation among instances. The forward relation, on a field called 'childof', works as exp

Re: ForeignKey Reverse Relation Fail

2022-07-27 Thread Malik Rumi
Thanks, but the recursive foreignkey *is* a one to many relationship... unless you're talking about something else? *“None of you has faith until he loves for his brother or his neighbor what he loves for himself.”* On Wed, Jul 27, 2022 at 10:16 AM Ammar Mohammed wrote: > Hi > Hav

Re: ForeignKey Reverse Relation Fail

2022-07-27 Thread Ammar Mohammed
Hi Have you tried using OneToMany relationship ? On 27 Jul 2022 12:18, "Malik Rumi" wrote: > I have a model with a recursive foreign key to 'self'. This is intended to > model a parent child > relation among instances. The forward relation, on a field called > 'childof', works as expected. > The

ForeignKey Reverse Relation Fail

2022-07-27 Thread Malik Rumi
I have a model with a recursive foreign key to 'self'. This is intended to model a parent child relation among instances. The forward relation, on a field called 'childof', works as expected. The reverse relation, using the related_name 'parent', comes up as a RelatedManager, again as expected.

Django Import Export, Filter ForeignKey objects connected to users

2021-11-17 Thread Gianmaria Di Fronzo
I'm building an import excel files system for every leads whit import export library. In the Website each user must be able to import his leads and make sure that they are viewed only by him. In all other cases I filtered the "organisation" field linked to a UserProfile model through the views.

How to test foreign key in clean() [was: Django Admin 3.1.7: getting RelatedObjectDoesNotExist for required ForeignKey]

2021-03-30 Thread Olivier
Hello, I could source the issue in a line in EthernetInterface clean() function. Here is the error triggering line: other_if = EthernetInterface.objects.exclude(server_host__pk=self.server_host.pk).filter(MAC=self.MAC).first() When I replace this line with ones bellow, behaviour is as expected

Django Admin 3.1.7: getting RelatedObjectDoesNotExist for required ForeignKey

2021-03-29 Thread Olivier
Hello, I'm using Django 3.1.7's Admin form of the following model: class EthernetInterface(models.Model): slug_name = models.CharField(max_length=32) MAC = MACAddressField(blank=True, null=True) lan = models.ForeignKey(LAN, on_delete=models.PROTECT, related_name='lan_interfaces')

Re: ForeignKey with different queryset from manager

2021-01-10 Thread Peter of the Norse
hey want undeleted items > and Model.all_objects when they want to included deleted items. > > We now have a situation where we want a ForeignKey, which uses objects, to > use all_objects instead. > > That is instead of this: > > ref_member = models.ForeignKey

ForeignKey with different queryset from manager

2020-12-14 Thread Jimmy Gawain
items and Model.all_objects when they want to included deleted items. We now have a situation where we want a ForeignKey, which uses objects, to use all_objects instead. That is instead of this: ref_member = models.ForeignKey(Member, related_name='+', null=True, blank=True, on_delete=models.CA

Re: Limit the choices for a ForeignKey

2020-10-11 Thread Dvs Khamele
Hi do you hire contract based python/django freelancer? We can help you in this and related techincal tasks at fair prices. Reply or send email to divy...@pythonmate.com Best Regards, Divyesh Khamele, Pythonmate On Sun, 27 Sep 2020, 10:09 pm Marco Paradisi, wrote: > Hi Everyone! > > I need to f

Re: Limit the choices for a ForeignKey

2020-09-27 Thread RANGA BHARATH JINKA
Hi, Check this. This may be useful for you. It is based on dependent dropdown. https://www.youtube.com/watch?v=U_qPp6vPl-g On Sun, Sep 27, 2020 at 10:09 PM Marco Paradisi wrote: > Hi Everyone! > > I need to filter the choices for a foreign key. > > My Model has an attribute SEX that co

Limit the choices for a ForeignKey

2020-09-27 Thread Marco Paradisi
Hi Everyone! I need to filter the choices for a foreign key. My Model has an attribute SEX that could be M or F, and two Foreign keys ( FATHER and MOTHER ), I want both filtered for sex. How can I achieve it? Thanks in advance -- You received this message because you are subscribed to the Goo

Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
Okay I figured it out. First I was using the wrong table (an old table that I should have deleted out). Second I needed to set the db_column attribute in my ForeignKey options). Works like a charm now. Sorry but thanks for the help! On Friday, September 11, 2020 at 11:59:56 AM UTC-5 Patrick

Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
OGUNSANYA I'm trying to access the related objects in the budget table from the Circuitinfotable. From what I can tell once they are related using the ForeignKey I should be able to do this with c.budget but it doesn't work for me. On Friday, September 11, 2020 at 10:43:39 AM UTC-5

Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Ogunsanya Opeyemi
Your ciecuitinfotable model does not have budget and budget_set field On Friday, September 11, 2020, Patrick Carra wrote: > hello I am attempting to relate two existing tables > > class Circuitinfotable(models.Model): > id1 = models.AutoField(primary_key=True, null=False, unique=True) >

Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
hello I am attempting to relate two existing tables class Circuitinfotable(models.Model): id1 = models.AutoField(primary_key=True, null=False, unique=True) pid = models.CharField(max_length=255, blank=True, null=True) circuitid = models.CharField(max_length=255, blank=True, null=True)

Re: Update _id field before .save() for ForeignKey

2019-11-30 Thread Dvenum
Thanks, its interest to know more about pk management, but this is another case. Now I update pk for child objects and this is fastest way, what I found. If django will reread .pk before save, it will the same. Want to know, maybe my logic can be altered from the start. How peoples create batch of

Re: Update _id field before .save() for ForeignKey

2019-11-30 Thread Integr@te System
Hi , Please lookandfeel on Moving an object from one database to another¶ https://docs.djangoproject.com/en/2.0/topics/db/multi-db/#moving-an-object-from-one-database-to-another On Sat, Nov

Re: Update _id field before .save() for ForeignKey

2019-11-30 Thread Dvenum
Integr@te System, This is True: id(company) == id(company_value.company) So, we have exact the same object company, .id is ready on .save() call, but internal meta dictionary still has None, because it was none when company_value created. On Sat, Nov 30, 2019 at 2:39 PM Integr@te System wrote:

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Integr@te System
Hi Dvenun, Bc of Django implement accord to python, of cause child inherit from parent existence. https://docs.python.org/3.7/library/functions.html#id On Sat, Nov 30, 2019, 13:30 Dvenum wrote: > Interest idea and it works, but not necessary: > company = Company() > #company.id is N

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Dvenum
Interest idea and it works, but not necessary: company = Company() #company.id is None companies.append(company) Company.objects.bulk_create(companies) #company.id is 1 Instead to ask pk from database, it can be used from company_value.company.id. Django save pk value to intern

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Charles Lee
I have an idea. 1. `bulk_create` all companies. 2. `Filter`(SELECT) all `Company` and make it dictionary for retrieving company fast. 3. 1. company_dict = { ’Name’: ‘pk’, ... } 4. Create a list of `CompanyValue` with company name and company_dict.

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Charles Lee
I have an idea. 1. `bulk_create` all companies. 2. `Filter`(SELECT) all `Company` and make it dictionary for retrieving company pk fast. 3. 1. company_dict = { ’Name’: ‘pk’, ... } 4. Create a list of `CompanyValue` with company name and company_dict

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Dvenum
Integr@te System, thanks. If I set pk (id) manually, it works, but hard to specify this id value. Maybe for one thread this way is good. On Fri, Nov 29, 2019 at 10:59 PM Integr@te System wrote: > Hi guy, > > I see this doc fix for u, with builtin pk in models django. > And you can create index i

Re: Update _id field before .save() for ForeignKey

2019-11-29 Thread Integr@te System
Hi guy, I see this doc fix for u, with builtin pk in models django. And you can create index in text/char field to optimize performance. https://docs.djangoproject.com/en/dev/ref/databases/#manually-specified-autoincrement-pk On Fri, Nov 29, 2019, 19:41 Maxim Bulatov wrote: > Hello, > > I hav

Update _id field before .save() for ForeignKey

2019-11-29 Thread Maxim Bulatov
Hello, I have lot of lists like follow: (Name1): (V1, V2, V3, V4, ..) And I use many threads to create many db objects: company = Company(Name) for x in vector: v = CompanyValue(company=company, value=x) values.append(v) class CompanyValue(models.Model): company = models.ForeignKey('

Re: I have two models which are associated to each other through a ForeignKey how to delete the child model object without affecting parent model object

2019-11-09 Thread Parth Joshi
Agree with Jordan. When you talk about CASCADE Delete to SET_NULL, those will matter when the parent table is deleted. For Example: User Field Type UserID INT Username VARCHAR Employee Field Type Relationship … some fields User INT Foreignkey(User, Userid) In this case: 1. If you

Re: I have two models which are associated to each other through a ForeignKey how to delete the child model object without affecting parent model object

2019-11-09 Thread Nijo Joseph
Since you are deleting the child model object none of these matters. But if you are deleting the parent model object on_delete matters. On Sat, 9 Nov 2019, 6:35 pm Jordan Micle, wrote: > when you use foreingkey you will set these options >> > here, change like this > on_delete=models.SET_NULL >

Re: I have two models which are associated to each other through a ForeignKey how to delete the child model object without affecting parent model object

2019-11-09 Thread Jordan Micle
> > when you use foreingkey you will set these options > here, change like this on_delete=models.SET_NULL user = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

I have two models which are associated to each other through a ForeignKey how to delete the child model object without affecting parent model object

2019-11-09 Thread Vignesh s
I have two models which are associated to each other through a ForeignKey how to delete the child model object without affecting parent model object -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

Re: setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Ok I found the source of the problem, which is the order of assigning and saving the b object. Saving first and assigning later works: b = B() b.save() instance.b = b On Sunday, September 22, 2019 at 10:53:32 AM UTC-3, Martín Massera wrote: > > Hi guys I'm posting this here before creating a

setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Hi guys I'm posting this here before creating a ticket, not sure if this is intended behavior but it looks like a bug to me. I have a pre_save method that populates a non-nullable OneToOneField in case it is not set at save time. class A(Model): b = models.OneToOneField(B, on_delete=CASC

Re: ForeignKey value while querying the model object

2019-09-05 Thread Jay Vasant
Please reply with your models schema. On Thu, Sep 5, 2019 at 7:56 AM dev wrote: > Hi All, > > How to get the ForeignKey value while querying the model object. > > > > I was trying to query a model object "mla" to fetch a specific sets of > columns and its wor

ForeignKey value while querying the model object

2019-09-04 Thread dev
Hi All, How to get the ForeignKey value while querying the model object. I was trying to query a model object "mla" to fetch a specific sets of columns and its working fine but the field ForeignKey i.e "instuid" returning a numeric value instant of actual associated

Re: Doesn't save data django Foreignkey model

2019-08-26 Thread Mark Ochieng
Sohel wrote: > > I've two model. I would like to save data from ForeignKey model. I'm > created a modelform and save with my main foreignkey model. But I got this > error ValueError at /c/customer/1/ Cannot assign "'1'": > "BillingData.customer

Doesn't save data django Foreignkey model

2019-08-25 Thread Asaduzzaman Sohel
I've two model. I would like to save data from ForeignKey model. I'm created a modelform and save with my main foreignkey model. But I got this error ValueError at /c/customer/1/ Cannot assign "'1'": "BillingData.customer" must be a "CustomerDat

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
OK. One work around could be to fire the signal manually just after you set/delete the value? I have not checked it yet :P Do one thing, implement pre_delete and post_delete signals and check the values of instance, sender and using. It might give you more information about what is happening.

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread mccc
On Thursday, March 14, 2019 at 4:22:15 PM UTC+1, Chetan Ganji wrote: > > Why do you need to do any calculations in the model code? > > I would do any calculations in the views and store them using models. That > will remove the getters and setters from model. > Everything should work fine then

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
That approach is not working for the original poster. So I gave him a solution that solves the problem. I meant, its my opinion to keep models slim and write utils to make the controllers slim. You don't have to follow it ;-) Follow what makes sense to you. I prefer it that way. Regards, Chetan

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Sithembewena L. Dube
There is nothing wrong with having logic in models. This is the principle of object orientation - encapsulating methods and properties in a class definition to group related behaviours and attributes of a specified type of entity. See the section titled "Make ‘em Fat" here: https://django-best-pr

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
Why do you need to do any calculations in the model code? I would do any calculations in the views and store them using models. That will remove the getters and setters from model. Everything should work fine then. Hope it helps. Regards, Chetan Ganji +91-900-483-4183 ganji.che...@gmail.com htt

on_delete not getting called when ForeignKey is a property

2019-03-14 Thread mccc
Hello, I have set up this nice model: class CustomGroup(models.Model): name = models.CharField(max_length=255) _parent = models.ForeignKey( "self", on_delete=models.CASCADE, null=True, related_name="descendants", db_column="parent" ) _depth = models.IntegerField(default=1

Lazy ForeignKey references break in upgrade from 1.9 to 1.10

2019-03-11 Thread James
Hey everyone, While upgrading from 1.9 to 1.10, I got errors that lazy ForeignKey references cannot be resolved similar to the following (full stack trace is included below): ValueError: Related model 'appname.ModelName' cannot be resolved This occurs with anything from simple

Re: Django ForeignKey field name “check” raises SystemCheckError

2019-02-20 Thread Tim Graham
I can use the > field name `check` as a ForeignKey. > > class Check(models.Model): > > > name = models.CharField(max_length=100) > > > class MyModel(models.Model): > > > # this works fine > #check = models.BooleanField() >

Django ForeignKey field name “check” raises SystemCheckError

2019-02-20 Thread Eric Palmitesta
, given the following example, it doesn't look like I can use the field name `check` as a ForeignKey. class Check(models.Model): name = models.CharField(max_length=100) class MyModel(models.Model): # this works fine #check = models.Boolean

Re: How to autosave Foreignkey value inside my second Model with the id of my first model object.??

2018-11-25 Thread Yavin Aalto Arba
dspace ,I have a Foreignkey object > in second model which connects to my first model. Here is the Code > > > models.py > > class Appname(models.Model): > > name=models.CharField(max_length=150,blank=False,null=False,help_text='Add > your new App') >

How to autosave Foreignkey value inside my second Model with the id of my first model object.??

2018-11-25 Thread Anoop Sharma
I have two models . Appname and Adspace ,I have a Foreignkey object in second model which connects to my first model. Here is the Code models.py class Appname(models.Model): name=models.CharField(max_length=150,blank=False,null=False,help_text='Add your new App') d

Re: module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread matteo gassend (LanguageMatt)
no problem Il 20 nov 2018, 18:38 +0100, Avitab Ayan Sarmah , ha scritto: > Thanks for your support. I will check and fix it. Thanks > > > On 20-Nov-2018 11:06 PM, "matteo gassend (LanguageMatt)" > > wrote: > > > A ForeignKey requires an “on_delete” argume

Re: module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread Avitab Ayan Sarmah
Thanks for your support. I will check and fix it. Thanks On 20-Nov-2018 11:06 PM, "matteo gassend (LanguageMatt)" wrote: A ForeignKey requires an “on_delete” argument. This is the function(kinda) that will be called when you decide to delete an instance of said model. You can see it

Re: module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread matteo gassend (LanguageMatt)
A ForeignKey requires an “on_delete” argument. This is the function(kinda) that will be called when you decide to delete an instance of said model. You can see it being used on the Django official tutorial, https://docs.djangoproject.com/en/dev/intro/tutorial02/#creating-models Il 20 nov 2018

Re: module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread Avitab Ayan Sarmah
Tuesday, November 20, 2018 at 10:29:26 PM UTC+5:30, matteo gassend wrote: > > the k in ForeignKey is Capitalized > Il 20 nov 2018, 17:57 +0100, Avitab Ayan Sarmah >, ha scritto: > > Hi everyone, > > I have written a code in models.py inside my project folder. I have > c

Re: module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread matteo gassend (LanguageMatt)
the k in ForeignKey is Capitalized Il 20 nov 2018, 17:57 +0100, Avitab Ayan Sarmah , ha scritto: > Hi everyone, > > I have written a code in models.py inside my project folder. I have completed > my code and whenever i execute "python manage.py makemigrations first_app",

module 'django.db.models' has no attribute 'Foreignkey'

2018-11-20 Thread Avitab Ayan Sarmah
Hi everyone, I have written a code in models.py inside my project folder. I have completed my code and whenever i execute "python manage.py makemigrations first_app", i get an error. The error is mentioned as "AttributeError: module 'django.db.models' has no attribut

Re: Need help with unique_together - on ForeignKey and Boolean field

2018-10-05 Thread Manjunath
pinned=False for the rest and I don't think that is how unique is supposed > to work. Unique is supposed to be different for all the objects right? not > sure how to tackle this problem. > > someone suggested I use a foreignkey field to link them all together but > now if

Re: Need help with unique_together - on ForeignKey and Boolean field

2018-10-05 Thread heriberto ochoa
t; sure how to tackle this problem. > > someone suggested I use a foreignkey field to link them all together but > now if I'm being honest, I actually do not know where to go from here > > ```class PinnedPost(models.Model): > pinned_post = models.ForeignKey(Post, related_name='

Re: Need help with unique_together - on ForeignKey and Boolean field

2018-10-05 Thread Chuka Nwadiogbu
the objects right? not sure how to tackle this problem. someone suggested I use a foreignkey field to link them all together but now if I'm being honest, I actually do not know where to go from here ```class PinnedPost(models.Model): pinned_post = models.ForeignKey(Post, related_nam

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread nelson fernando garcia gomez
; self.fields['destination'].widget.attrs['disabled'] = True >>> at the end of your __init__(..). >>> >>> >>> W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson >>> fernando garcia gomez napisał: >>>> >&g

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread nelson fernando garcia gomez
garcia gomez escribió: > > Hola estoy tratando en mi formulario (formsModel) implementar el atributo > de *readonly* a una foreignkey (ModelChoiceField) > pero no es posible alguna ayuda por favor GRACIAS así lo estoy haciendo: > class CostoForm(forms.ModelForm): > > "

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread nelson fernando garcia gomez
bled = True >>> >>> in lower versions you should add >>> self.fields['destination'].widget.attrs['disabled'] = True >>> at the end of your __init__(..). >>> >>> >>> W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread Mateusz
iu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson fernando >> garcia gomez napisał: >>> >>> Hola estoy tratando en mi formulario (formsModel) implementar el >>> atributo de *readonly* a una foreignkey (ModelChoiceField) >>> pero no es pos

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread nelson fernando garcia gomez
s['disabled'] = True > at the end of your __init__(..). > > > W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson fernando > garcia gomez napisał: >> >> Hola estoy tratando en mi formulario (formsModel) implementar el atributo >> de *readonly* a

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-19 Thread nelson fernando garcia gomez
s['disabled'] = True > at the end of your __init__(..). > > > W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson fernando > garcia gomez napisał: >> >> Hola estoy tratando en mi formulario (formsModel) implementar el atributo >> de *readonly* a

Re: Readonly ModelChoiceField of type in model foreignkey

2018-09-18 Thread Mateusz
of your __init__(..). W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson fernando garcia gomez napisał: > > Hola estoy tratando en mi formulario (formsModel) implementar el atributo > de *readonly* a una foreignkey (ModelChoiceField) > pero no es posible alguna ayu

Readonly ModelChoiceField of type in model foreignkey

2018-09-18 Thread nelson fernando garcia gomez
Hola estoy tratando en mi formulario (formsModel) implementar el atributo de *readonly* a una foreignkey (ModelChoiceField) pero no es posible alguna ayuda por favor GRACIAS así lo estoy haciendo: class CostoForm(forms.ModelForm): """ Edicion de Costos con formset. "&quo

Re: Models which link to Groups (by ForeignKey)

2018-09-10 Thread Benjamin SOULAS
Ow, ok, I got it, thx a lot But in order to create this object (retrieve my groups from the ORM), should I implement something specific? Because for my request, I just want to specify the group names and then, in my app, retrieve those, create my link between the groups... I thought I had to r

Re: Models which link to Groups (by ForeignKey)

2018-09-10 Thread Jason
https://stackoverflow.com/questions/2642613/what-is-related-name-used-for-in-django As you can see there, its for the relation from Group to GroupLinker. That relation name is the same for both fields, so you need to specify something unique. -- You received this message because you are subsc

Models which link to Groups (by ForeignKey)

2018-09-10 Thread Benjamin SOULAS
Hello everyone, I want to implement a model which make references to 2 groups, to do this, I thought I had to defined, in the model which links the 2 groups, a foreign key for each Group like this: from django.contrib.auth.models import Group from django.db import models class GroupLinker(mod

Cannot assign the current user to the ForeignKey field in my model.

2018-06-23 Thread Saloni Kalra
I am trying to build a feedback application for the teachers by the students. I have a proxy User that will the student. But I am not able to assign the user to the feedback model. I am a newbie. Please help. Thanks and regards, Saloni *models.py:* class User(auth.models.User, auth.models.Permiss

Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-30 Thread Jim Illback
te: Absolutely agree. The “instance” (your note) is for Checkin and it includes a ForeignKey field to ChoreTime, which is a selection (choice field). But, I want that choice field to be limited for the forms to be only what has been not assigned yet. That way the user on the page will know that any sho

RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
ields[‘choretime’].queryset |= ChoreTime.objects.filter(pk=self.instance.choretime.pk) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Jim Illback Sent: Friday, April 27, 2018 1:39 PM To: Django users Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceFi

Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
Absolutely agree. The “instance” (your note) is for Checkin and it includes a ForeignKey field to ChoreTime, which is a selection (choice field). But, I want that choice field to be limited for the forms to be only what has been not assigned yet. That way the user on the page will know that any

RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
= CheckInForm(request.POST or None, instance=instance) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Jim Illback Sent: Friday, April 27, 2018 11:33 AM To: Django users Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values I also need to

Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
helps! From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> [mailto:django-users@googlegroups.com] On Behalf Of Jim Illback Sent: Friday, April 27, 2018 11:16 AM To: Django users Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values To make this eas

RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Jim Illback Sent: Friday, April 27, 2018 11:16 AM To: Django users Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values To make this easier, here is just a simple the question. Does Django give a

Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
To make this easier, here is just a simple the question. Does Django give a method that can be overridden while processing a form which has access to the incoming URL parameters and precedes the display of the form’s fields, specifically being able to alter the fields’s query set before it is d

Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-25 Thread Jim Illback
I wondered if anyone has had to alter the queryset behind a model form’s foreign key field which presents as a model choice field? Briefly, I have a client attribute table with the foreign key to a chore/time table. For an add of the client attribute table, I want to limit entries to unassigned

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-03-01 Thread Alexander Joseph
I think the solution is above my head at the moment. I'll have to look back into it once I get better at Django. Thanks for your help though On Tuesday, February 27, 2018 at 7:26:22 AM UTC-7, Alexander Joseph wrote: > > Is there a way to make a form field or model field either a foreign key >

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-28 Thread Mike Dewhirst
to either select a user from a drop down list of users from the ForeignKey in the Users model, or if there is not a user suitable to select in the drop down, they can manually type in a name themselves. In the same field that would require a hack of the first water.  Way

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-28 Thread Matemática A3K
On Wed, Feb 28, 2018 at 12:46 AM, Mike Dewhirst wrote: > On 28/02/2018 1:58 PM, Alexander Joseph wrote: > >> Sorry, I think my question was confusing. What I want to do is allow the >> user to either select a user from a drop down list of users from the >> ForeignKey i

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-27 Thread Mike Dewhirst
On 28/02/2018 1:58 PM, Alexander Joseph wrote: Sorry, I think my question was confusing. What I want to do is allow the user to either select a user from a drop down list of users from the ForeignKey in the Users model, or if there is not a user suitable to select in the drop down, they can

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-27 Thread Alexander Joseph
Sorry, I think my question was confusing. What I want to do is allow the user to either select a user from a drop down list of users from the ForeignKey in the Users model, or if there is not a user suitable to select in the drop down, they can manually type in a name themselves. Thanks for

Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-27 Thread Mike Dewhirst
user if possible, and if not possible be able to fill in a name myself. Yes. Make the ForeignKey in the model null=True and blank=True so it can exist all alone. Then you can limit_choices_to whatever whatever suits your requirements ... https://docs.djangoproject.com/en/1.11/ref/models/f

Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-27 Thread Alexander Joseph
Is there a way to make a form field or model field either a foreign key reference or allow the user to fill in something themselves? I'm making a fixed assets app and each fixed asset has an owner field, which I would like to assign to an app user if possible, and if not possible be able to fil

Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Kubilay Yazoğlu
other one. Since this is done in Django by only specifying the Class >>>> name, without specifying the field name(column name), when I try to create >>>> an object in admin panel, it pulls the wrong column information. >>>> >>>> Two models A

Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Kubilay Yazoğlu
foreign key to the > other one. Since this is done in Django by only specifying the Class name, > without specifying the field name(column name), when I try to create an > object in admin panel, it pulls the wrong column information. > > Two models A and B. > B has a Foreignkey

Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Matemática A3K
on, that won't happen, a primary key is unique. If you add a > record with the same key Django will raise an IntegrityError. > > >> I'm talking about the unique_together case. >> > > I don't understand you > The ForeignKey uses the mod

Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Matemática A3K
gt;> name, without specifying the field name(column name), when I try to create >>> an object in admin panel, it pulls the wrong column information. >>> >>> Two models A and B. >>> B has a Foreignkey for accessing A. >>> A has two fields Field1 and Fi

Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Kubilay Yazoğlu
name, >> without specifying the field name(column name), when I try to create an >> object in admin panel, it pulls the wrong column information. >> >> Two models A and B. >> B has a Foreignkey for accessing A. >> A has two fields Field1 and Field2. >> When I

Re: How to select the proper column when I use ForeignKey?

2017-11-26 Thread Matemática A3K
y only specifying the Class name, > without specifying the field name(column name), when I try to create an > object in admin panel, it pulls the wrong column information. > > Two models A and B. > B has a Foreignkey for accessing A. > A has two fields Field1 and Field2. > When I try

How to select the proper column when I use ForeignKey?

2017-11-26 Thread Kubilay Yazoğlu
A and B. B has a Foreignkey for accessing A. A has two fields Field1 and Field2. When I try to create an instance of B, in the field of Foreignkey, there is a drop down menu but the content is not from the right field of A. How to specify it? -- You received this message because you are

Re: Getting my head around ForeignKey, One-To-Many and Many-To-Many.

2017-09-16 Thread Ryan Nowakowski
Instead of using ManyToMany in stencil, add a ForeignKey(EditorStencil) in vocab. On September 13, 2017 6:25:32 PM CDT, Jack Razors wrote: >I am creating a mindmap visio-like editor website using d3js and a >bunch of >custom javascript. Rather than the schema/stencils being pop

Getting my head around ForeignKey, One-To-Many and Many-To-Many.

2017-09-13 Thread Jack Razors
I am creating a mindmap visio-like editor website using d3js and a bunch of custom javascript. Rather than the schema/stencils being populated by static JSON files, I wanted to create an administration area to edit the schema without requiring JSON kung-fu skills and serve the dynamically gene

Not able to see the dropdown field for Foreignkey ModelForm.

2017-05-18 Thread Vipul Ujawane
This is my code: *#models.py* class Subject(models.Model): departement_code=models.CharField(max_length=2,blank=False) subje

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2016-11-25 Thread Michael Viveros
Victor Hooi, did you ever find a work-around? I'm having the same problem of trying to efficiently create models that have a Many to One relationship (so that they are linked by a Foreign Key). The ticket referenced above is still open and I manually

  1   2   3   4   5   6   7   8   9   10   >