A
A
Alexander Mironenko2020-04-26 08:17:53
Django
Alexander Mironenko, 2020-04-26 08:17:53

Changing a user's static page of a django site in the admin?

How model.py, views.py and urls.py should look like so that the user can easily change the title, text and background in the site header.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2020-04-26
@agmiro1956

to the heap - there are more flatpages

V
Vladimir, 2020-04-26
@Realmixer

I won't write the code for you. But in general, it may look like this...
In models, oddly enough, write a model with all the necessary fields - name, text, background, addresses and phone numbers... If you use django sites , then you can bind it to the site model through OneToOneField .
In views, one class inherited from UpdateView suffices . In it, you override the get_object method so that an instance of the settings model is created if it does not exist in the database.
It makes no sense to write about urls - this is an auxiliary code.
Good luck!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question