Nature language  of this  maillist is English.  Please keep this in mind
Take a look at the example at
https://docs.djangoproject.com/en/1.8/topics/db/queries/
 your task is subpart of the task in  documentations.

 General procedure is next :
 1) set user authorization
1a) This is not important but can be usefull : Add  to the user profile
last edited book
2)  User select  book  or use  default choice
3)  User  create a page  which is used ID (slug) of the book in constructor

 Also you url.py should looks like :

urlpatterns = [
    url(r'^(?P<slug>[-\w]+)/$', PageCreateView.as_view()),]

 Where P<slug>[-\w+] is a slug field of the edited book
 or P<pk>\d+  for Key usage


Many thanks,

Serge


+380 636150445
skype: skhohlov

2015-12-06 14:39 GMT+02:00 Валерий Бовсуновский <id290...@gmail.com>:

> В просто варианте получается так как, я понимаю. Модель Book и связанная с
> ней модель Pages, связанная многие к одному.
>
> class Book(models.Model):
>     book = models.CharField(max_length=200)
>
>     def __unicode__(self):
>         return self.book
>
> class Pages(models.Model):
>     connect = models.ForeignKey(Book)
>     pages = models.TextField(blank=True, verbose_name='Страница')
>
>
>
> Не сходится у меня или чего то упускаю. У меня 300 пользователей.
> Каждый допустим создаст книгу.
> Тогда при выбое страницы, придётся выбирать из списка с 300 книг.
>
> Как сделать так, что бы когда пользователь при создании книги, страницы,
> которые он будет добавлять по умолчнаю уже выбирали его новую книгу.
> Я так понимаю нужно это как то прописать. Как забронировать это?
>
> Общая идея такая. Я хочу избежать личных аккаунтов пользователей.
> Что бы н было блуждания по аккаунтам а всё находилось в одном месте.
>
> Сейчас начала описывать Rest Framework дам начало и основные возможности.
> Но потом хочу дать возможность, что бы когда люди научаться, то будут
> добавлять свой опыт.
>
> Для этого.
>
> а)
> 1. Создам три рубрики и свяжу их с книгами. (здесь это модели пока нет)
> 1. Начало работы.
> 2. Рецепты
> 3. Лучшие практики.
> Здесь мне всё понятно. Добавлю ещё одну связь и человек будет выбирать из
> трёх рубрик, куда добавить свою книгу. - это мне понятно. (книги будут
> выводмится по категориям)
>
>
> б) Пользователь может иметь много книг и их можно отдельно вывести. Здест
> тоже нет проблем (создам отношение к User один к одному) - это тоже понятно.
>
> в)
> Остается, только не понятно то что описал выше. Что бы при создании книги,
> страницы присоединялись именно к вновь созданной книге, без выбора из
> списка из всех книг.
>
>
> воскресенье, 6 декабря 2015 г., 1:33:32 UTC+3 пользователь Sergiy Khohlov
> написал:
>>
>> Two models book and page. Page has key field to book . page is attached
>> to the book page as related object.
>> 5 груд. 2015 17:42 "Валерий Бовсуновский" <id29...@gmail.com> пише:
>>
>>> But I can not figure out how to write the code to add a page.
>>>
>>> Guys, please natolknite the idea. If possible, reset the reference to an
>>> example or help section.
>>> I can not understand. I want to do a book on the website:
>>> What would each user can create a book. (unlimited number of pages)
>>> But I can not figure out how to write the code to add a page.
>>> Thank you so much.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/f3d8d77b-4e91-4aec-819b-844e79258a14%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/f3d8d77b-4e91-4aec-819b-844e79258a14%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ae74e0ba-a077-4246-a5ad-6b2dce3e8294%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ae74e0ba-a077-4246-a5ad-6b2dce3e8294%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJN6d3KHF5mrcLLgAttW6zR2%3DC85FufTwz--PYi4wt71mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to