Can some one help explain the following page to me http://nullege.com/codes/search/zinnia.models.Entry.objects.create
How do I create a entry in zinnia with a form.html file and a view function in django
I know it's basic python playing around with classes
the hellow world can be found here http://django-blog-zinnia.com/blog/
For your first question:
Here
Entry.objects.create(**params)
is equivalent to `Entry.objects.create(title='My entry 1', content='My conten 1', tags='zinnia, test', slug='my-entry-1', status='PUBLISHED'), which creates a new Entry with title "My entry 1" and content "My content 1" and saves to the database. The base entry class looks something like this:so lines like
self.entry_1.authors.add(self.authors[0]
will relateself.athors[0]
toself.entry_1
throughManyToManyField
.As for your second question, yes you can create a
form.html
and a view function to add a new entry, but zinnia is designed to be used with Django Admin interface to manage contents. It would also make your life much easier. To use it you will need to enable'django.contrib.admin',
inINSTALLED_APPS
in yoursettings.py
and also theurls.py
files.After Django admin is enabled, you can simply go to
example.com/admin/
to create new entries.Now, if for some reason you do not or cannot use the Django admin, here is what the
views.py
would look like to add new entries:Note that you would also need to create a
forms.py
to validate the submitted form.As for your
forms.html
you would need to write a form that contains all the inputs you need such as "title" and "contents" and have it POST to thisadd_entry
view.