On Dec 14, 2007 9:36 AM, Nianbig <[EMAIL PROTECTED]> wrote:

>
> Hi
>
> I have two models, Category and News. I have linked them to eachother
> through a ForeignKey in News... when I add a new newsitem I would like
> to pick the category it belongs to.
>
> I have two problems I can´t figure out:
> 1. I would like to be able to save a news item with a blank Category,
> Djangos admin doesn´t seem to accept this even though I have added
> "null=True"... is there some other way to set which fields who should
> be required?


Yes, see the description of blank right underneath null in the docs here:

http://www.djangoproject.com/documentation/model-api/#null


>
> 2. When I choose the category when adding a newsitem the Category
> title doesn´t show up in the selectbox, instead there´s just "Category
> object", "Category object", "Category object" etc.. how do I set which
> field in the Category class I would like to have in the selectbox?
>

Sounds like you have not defined a __str__() or __unicode__() method for
your models.  As noted here:

http://www.djangoproject.com/documentation/tutorial01/#playing-with-the-api

"It's important to add __unicode__() methods to your models, not only for
your own sanity when dealing with the interactive prompt, but also because
objects' representations are used throughout Django's
automatically-generated admin."

Whether you want __str__ or __unicode__ depends on what version of Django
you are using.  0.96 release you should define __str__, for a more recent
svn checkout you should define __unicode__.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to