the problem is that in the admin area the first class shows up with another s. Instead of being Locaciones reads Locacioness and when I try and add a location it wont show the actual name given, just shows Locaciones object (3) even when selecting from the drop down menu on the Eventos table, furthermore I tried to solve this by changing the class name from Locacion to Locaciones because I was having the same issue where the admin area adds an s to the class name. This is the first app I code in any capacity so Im out of ideas, a glitch maybe?
Hey thanks for the quick reply, I’m following a tutorial and it looks to me I’ve been writing the exact same models and his tables don’t behave like that, on the +s thing nor the form fields, so I’m confused, is this a different version issue or am I missing something on his tutorial?
thanks
I don’t know how deeply you want to look into this, but on the surface level…you can re-define the plural name with verbose_name_plural=“newname” (ie. look at link posted by Ken), add it to your model as the last option in the list of options/arguments you apply to the model.
Hey, thanks for taking the time to reply, I was trying to figure where to add the verbose option to my model, I really don’t mind the name, but would like to figure out why would that be necessary as an expected behavior, actually the real issue is that the actual entries are shown as objects on the admin page, so going through the documentation I’m wondering if I need to use the classmodels.LogEntry.object_id
method so I get the name not the object 1 string that is being returned; and pardon my ignorance but such model should be placed on the models.py file and should I be importing any file in particular up top?
Does this sound like it would work?
thanks
The admin is not the only place where the pluralized name is available. So yes, the definition of the pluralized name goes in the Meta class of the model. You add an entry in that class for verbose_name_plural.
Because it’s the defined and designed behavior of how Django works.
Regarding your other question - the links provided to the documentation explain that the select list entries are created by the output of the __str__ method on the model class. Overriding that method on the related class is the easiest way to change the representation of that class in the admin.
It is entirely to do with how you define the field object name. You don’t need to import anything special. If you want a code example can make it, it’s been said: define def __str__ to return exactly what you want, so it wont be returning object(3) or something like that. When you omit __str__ that’s what happens.
hi Ken, the necessary expected behavior question was more on the practical ways that may be useful or is it convention to do it, kinda way, wasnt trying to be snotty, I appreciate you taking the time to answer noobs like me, Ill just take some time to work through it, thank you for your replies!