Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django OperationalError
i start to learn django and i want to crate models the first one work and then i want to make another and i go to the admin panel and this happen[https://i.stack.imgur.com/rg8oO.png] can somone help me with that[https://i.stack.imgur.com/7Da01.png] [https://i.stack.imgur.com/SGEiX.png] -
Guzzle http and Laravel Http post method replace with get method
I create guzzle client using post method but it replaced to get method. I try to use Illuminate\Support\Facades\Http on Laravel 7.x but get the same error. The API server is Django Rest Framework. see Illuminate\Support\Facades\Http doc at : https://laravel.com/docs/7.x/http-client#request-data Http::withHeaders([ 'Authorization' => "" ])->post('http://domain.id/api/v1/test', [ "parameter" => "value", ]); Result using Laravel Illuminate\Support\Facades\Http The method is GET instead of POST -
Obtain the last "n" values from my model from all my devices
I want to obtain the last values of my different devices from my data model. If I want the last one I'm using, dev_data = DevData.objects.order_by('dev_id','-data_timestamp').distinct('dev_id') But I don't know how to obtain the last "n" values of each one (not just the last one). I tried this, but is wrong. dev_data = DevData.objects.order_by('dev_id','-data_timestamp').distinct('dev_id')[:n] Can somebody help me? Thank you very much! -
Django Exception
i have a question. Im working on a Web-app and i included the Google API. Everything works fine and now i want to add some stuff for good Messages for the users. The Problem now is, that i build a try - except with the request inside: try: results = service.users().list(customer='my_customer', maxResults=10, orderBy='email').execute() response = HttpResponse.status_code except Exception: return "error" In this case, response is 200, thats good. But when i make a bad reqeust like: try: results = service.users().list(customer='my_customer', maxResults=10, orderBy='wdadwadwa').execute() response = HttpResponse.status_code except Exception: return "error" #I want to return the error code here Or i change Scope to a wrong scope whatever i recieve a code 200. And this is right because we have the try-except block there. But i need the original code. Like 404, 403 or whatever. I want to return the Code to create Messages for users. Like 403 - better contact the admin etc. How can i get the original http response from the error? The HttpRespone.status_code doesnt work in this case. Any ideas? -
Autocomplete does nothing. What is wrong?
Guys i am learning how to make autocomplete. Explored many resources and watched tutorials but it seemed i miss something and my code does nothing. I would be very happy to get your help as i am struglling with it for over week for now. What i did so far: In models.py i have: class Coordinate(models.Model): code = models.CharField(max_length=150) class Profiles(models.Model): geocode=models.CharField(max_length=200) country=models.CharField(max_length=500) class Meta: managed=False db_table='profiles_country' def __str__(self): return '{}'.format(self.geocode) in forms.py: from dal import autocomplete class CoordinateForm(forms.ModelForm): code= forms.CharField(max_length=150, label='',widget= forms.TextInput) class Meta: model = Coordinate fields = ('__all__') widgets = { 'code': autocomplete.ModelSelect2(url='coordinate-autocomplete', attrs={ 'theme': 'bootstrap'})} def clean_code(self): code=self.cleaned_data.get("code") if not Profiles.objects.filter(geocode=code).exists(): raise forms.ValidationError ( "Not true") return code in views.py: from dal import autocomplete def geoview(request): form = CoordinateForm(request.POST or None) if request.method == "POST": if form.is_valid(): form1 = form.save(commit=False) code = form1.code dataview=Profiles.objects.get(geocode=code) context={'geodata':dataview ,} return render(request, 'cgeo/result.html', context) return render(request, 'cgeo/search.html', context={'form':form}) class CoordinateAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): if not self.request.user.is_authenticated(): return Profiles.objects.none() qs = Profiles.objects.all() if self.q: qs = qs.filter(name__istartswith=self.q) return qs in main urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('geo/', geoview, name='geo'), path('coordinate-autocomplete/', CoordinateAutocomplete.as_view(create_field='name'), name='coordinate-autocomplete'),] in geo.html : {% extends "base.html" %} {% block content %} {% if user.is_authenticated %} <form enctype="multipart/form-data" method="POST" > … -
Headers not visible in ModelAdmin get_form()
My model is such that each website has an associated email address. An administrator would select a set of websites on the website list view and use an admin action to pass the email addresses of the selected websites to recipient field of a new email_message object. From here, the administrator should be able to customize an email that is sent to each of those email addresses. The problem is that I can't pass headers to the get_form() method in the new email_message view. When I run the code, the print function that you see included here prints <QueryDict: {}>. How can I pass header data from an admin action to another model's get_form method? admin.py: def email_selected(modeladmin, request, queryset): response = HttpResponseRedirect('/admin/websites/email_message/add/') response['queryset'] = queryset return response class WebsiteAdmin(admin.ModelAdmin): actions = [email_selected] class Email_messageAdmin(admin.ModelAdmin): def get_form(self, request, obj, **kwargs): print(request.GET) form = super(Email_messageAdmin, self).get_form(request, obj, **kwargs) return form Thank you in advance for your time. -
How to use a DatePicker in a ModelForm in django 3.0?
I am using django 3.0 and I am trying to display a datepicker widget in my ModelForm, but I can't figure out how (all I can get is text field). I have tried looking for some solutions, but couldn't find any. This is how my Model and my ModelForm look like: class Membership(models.Model): start_date = models.DateField(default=datetime.today, null=True) owner = models.ForeignKey(Client, on_delete=models.CASCADE, null=True) type = models.ForeignKey(MembershipType, on_delete=models.CASCADE, null=True) class MembershipForm(ModelForm): class Meta: model = Membership fields = ['owner', 'start_date', 'type'] widgets = { 'start_date': forms.DateInput } And this is my html: <form class="container" action="" method="POST"> {% csrf_token %} {{ form|crispy }} <button type="submit" class="btn btn-primary">Submit</button> </form> -
Django Channel 2 with Daphne on Heroku crash on starting
I created a django app using Channels 2 on heroku but it crash on starting with 503 error code. 2020-04-07T10:05:35.226253+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.mysite.com request_id=317bfbe6-9055-4957-9fbb-8190616c3964 fwd="" dyno= connect= service= status=503 bytes= protocol=https Procfile : release: python manage.py migrate web : daphne myproject.asgi:application --port $PORT --bind 0.0.0.0 -v2 worker: python manage.py runworker channels -v2 settings.py ASGI_APPLICATION = 'myproject.routing.application' # Channels CHANNEL_LAYERS = { "default": { 'BACKEND': 'channels_redis.core.RedisChannelLayer', "CONFIG": { "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')], }, }, } asgi.py import os import django from channels.routing import get_default_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") django.setup() application = get_default_application() -
Hello i am trying to run my django app in pythonanywhere and i get this error .does by any chance anyone experienced something similar isues?
error log 2020-04-07 09:50:50,115: *************************************************** 2020-04-07 09:50:50,115: If you're seeing an import error and don't know why, 2020-04-07 09:50:50,115: we have a dedicated help page to help you debug: 2020-04-07 09:50:50,115: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-04-07 09:50:50,115: *************************************************** 2020-04-07 09:50:53,872: Error running WSGI application 2020-04-07 09:50:53,873: ModuleNotFoundError: No module named 'psych_test_demo' 2020-04-07 09:50:53,873: File "/var/www/evaldasmencinskas_pythonanywhere_com_wsgi.py", line 14, in <module> 2020-04-07 09:50:53,873: application = get_wsgi_application() 2020-04-07 09:50:53,873: 2020-04-07 09:50:53,874: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2020-04-07 09:50:53,874: django.setup(set_prefix=False) 2020-04-07 09:50:53,874: 2020-04-07 09:50:53,874: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup 2020-04-07 09:50:53,874: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 2020-04-07 09:50:53,874: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__ 2020-04-07 09:50:53,875: self._setup(name) 2020-04-07 09:50:53,875: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup 2020-04-07 09:50:53,875: self._wrapped = Settings(settings_module) 2020-04-07 09:50:53,875: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__ 2020-04-07 09:50:53,875: mod = importlib.import_module(self.SETTINGS_MODULE) 2020-04-07 09:50:53,875: *************************************************** 2020-04-07 09:50:53,875: If you're seeing an import error and don't know why, 2020-04-07 09:50:53,875: we have a dedicated help page to help you debug: 2020-04-07 09:50:53,876: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-04-07 09:50:53,876: *************************************************** i tried using diferent names for virtualenv like mysite-virtualenv and psych_test_demo-master i got installed everything required for app to work like django and xlsxwriter this is how my wsgi.py file looks like.i got python 3.8 here. … -
How do I test an Assertion Error thrown from my actual code in Django? [duplicate]
I am testing a function in Django using testcases.TestCase. I this function it is calling another function which asserts the passed parameters, and may throw AssertionError with a message. def another_func(data): assert len(data) > 0, 'Data cannot be empty' assert isinstance(data, dict), 'Input data must be a dict' # other code How do I test the returned error string? -
Using select2 on custom django forms and model forms
While reading the documentation of https://github.com/applegrew/django-select2, there is a note: "Django's admin comes with builtin support for Select2 since version 2.0 via the autocomplete_fields feature." I was able to enable autocomplete_fields for my admin site forms. The question is, is there any built-in functionality for custom and model forms where I need not install any third-party libraries? Is there any way I can leverage already included select2 functionality (for admin site) for model forms? I tried searching the same on google but could not find any documentation. This code is irrelevant but I thought my question should have some code so. models.py from django.db import models class Market(models.Model): CHOICES = [ ('IN', 'India'), ('US', 'United States'), ('EP', 'Europe'), ('JP', 'Japan') ] name = models.CharField(max_length=3, choices=CHOICES, blank=True, unique=True) class Product(models.Model): markets = models.ManyToManyField(Market) admin.py from django.contrib import admin class MarketAdmin(admin.ModelAdmin): search_fields = ['name'] class ProductAdmin(MarkdownxModelAdmin): autocomplete_fields = ['market'] forms.py from django.forms import ModelForm class ProductForm(ModelForm): class Meta: model = Product fields = ['markets'] -
Django REST Framework : ManyToMany relationship
I'm currently working on a Django project, I'm new at this and it's difficult to find clear documentation about this. My issue is very simple, I want at the creation of my model, automatically associate another model through a ManyToMany relationship. Here goes the code : Serializer : class FavoriteSerializer(serializers.ModelSerializer): estates = EstateSerializer(read_only=True, many=True) class Meta: model = Favorite fields = ['uuid', 'title', 'estates'] def create(self, validated_data): instance = super(FavoriteSerializer, self).create(validated_data) instance.save() return instance ViewSet : class MyFavoriteEstatesListViewSet(viewsets.ModelViewSet): serializer_class = FavoriteSerializer def get_queryset(self): return Favorite.objects.filter(users__id=self.request.user.id) I'm currently sending something like this through a POST : {"title": "some title", "estate_uuid": "XXX"} I just wanted to instantiate my Estate model with the UUID I just sent and adding it with favorite.estates.add(estate) How can I achieve this ? Thanks for your help ! -
GeoDjango migrate giving the following error - ValueError: Cannot use object with type int for a spatial lookup parameter
I'm trying to create a model with Geospatial field. When I try to migrate I receive the following error: Apply all migrations: admin, auth, contenttypes, map, sessions Running migrations: Applying map.0008_territorio_geometry...Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\base.py", line 369, in execute output = self.handle(*args, **options) File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "C:\Users\Marco\Envs\um\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle post_migrate_state = executor.migrate( File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration state = migration.apply(state, schema_editor) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\migrations\migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\migrations\operations\fields.py", line 110, in database_forwards schema_editor.add_field( File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\backends\base\schema.py", line 450, in add_field definition, params = self.column_sql(model, field, include_default=True) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\backends\base\schema.py", line 223, in column_sql default_value = self.effective_default(field) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\backends\base\schema.py", line 303, in effective_default return field.get_db_prep_save(self._effective_default(field), self.connection) File "C:\Users\Marco\Envs\um\lib\site-packages\django\db\models\fields\__init__.py", line 821, in get_db_prep_save return self.get_db_prep_value(value, connection=connection, prepared=False) File "C:\Users\Marco\Envs\um\lib\site-packages\django\contrib\gis\db\models\fields.py", line 147, in get_db_prep_value super().get_db_prep_value(value, connection, … -
nesting of serializer in django
I wanted to access the details of other models while using the serializers and sending the json data back. However, when I am using the different models related to each other. It is not populating the data when I hit the API in postman. The Models I have are as follows: class OPlAss(models.Model): occ = models.ForeignKey(Occas) play = models.ForeignKey(Playlist) s_order = models.IntegerField(blank=True,null=True) s_nb_songs = models.IntegerField(blank=True, null=True) class Occas(models.Model): name = models.CharField(max_length=255, blank=True, null=True) description = models.TextField(blank=True, null=True ) playlists = models.ManyToManyField("Playlist", through='OPlAss', blank=True) class Playlist(models.Model): songs = models.ManyToManyField('Song', through='PlSongAss') Now I am creating a serializer of Occas, wherein I need the id, playlist, songs(which are in the playlist). class PlaylistSongSerializer(serializers.ModelSerializer): songs = serializers.SerializerMethodField() class Meta: model = OccassionPlAssociation fields = ('id','sequence_order','sequence_nb_songs','songs') @staticmethod def setup_eager_loading(queryset): queryset = queryset.prefetch_related('songs') return queryset def get_songs(self, obj): return obj.songs.all() class OccasionSerializer(serializers.ModelSerializer): playlists = PlaylistSongSerializer(many = True) class Meta: model = Occasion fields = ('id','name','algo_type','description','playlists') I get the output as below: [ { "id": 2, "name": "Test Brunch Mix", "description": "for testing", "playlists": [ { "id": 72, "songs": [] } ] }, { "id": 1, "name": "Test Halloween Mix", "description": "Perfect mix to bring all ghouls to the club.", "playlists": [ { "id": 467, "songs": [] … -
How to write complex select query in Django ORM
This select query is giving the result of all the channels where I am the admin and its order is most recent chat channel is on top. I want to make such a query in Django.. can anyone help me how can I create such a query in Django ORM? select c.id, c.name, CASE WHEN cc.created is null THEN '1970-01-01' ELSE cc.created END AS created FROM channel as c LEFT JOIN channel_admin as m on m.channel_id=c.id LEFT JOIN channelchats as cc on cc.channel_id=c.id AND cc."created" = ( SELECT max("created") FROM xchat_channelchats r1 WHERE c.id = r1.channel_id ) WHERE m.user_id=12 GROUP BY c.id, m.channel_id, cc.created ORDER BY created DESC; -
How do I model a team registration system in Django once a user logs in and get it to show on the homepage?
I'm trying to create a hackathon management system using Django 3. I've created an app 'accounts' which takes care of normal user registration to my website (name,email etc). In the backend django interface, I add these registered users manually to a list of hackathons I've created. The homepage of my website shows the list of hackathons and the people registered for them. Now what I want is for this logged in user to click on say, a register button on the homepage's sidebar which allows him/her to add names of his/her teammates, select a hackathon thereby registering themselves. Similar to what happened previously, I'd like the team names and details to show up on the homepage. How do I do this? These are the contents of my models.py files from the 'accounts' app: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) # social github = models.CharField(max_length=30, null=True, blank=True) linkedin = models.CharField(max_length=30, null=True, blank=True) #others = models.CharField(max_length=30, null=True, blank=True) # tags TAGS = [ ('New', 'Newbie'), ('Developer', 'Developer'), ('Business', 'Business'), ('Designer', 'Designer'), ] phone = models.CharField(max_length=10, blank=True, default='') skillset = models.CharField(max_length=200, blank=True, default='') tags = models.CharField(max_length=15, default='New', choices=TAGS) bio = models.TextField(max_length=900, blank=True, default='') def __str__(self): return self.user.username # signal - every time a … -
Django filter for all items which contain at least one null value
An answer elsewhere on SO provides the Postgresql NOT(<table> IS NOT NULL) query as an option to find all rows in a table containing one or more null values. How would one apply this query in the Django ORM without writing raw SQL? Or is this a case where raw SQL is required? I couldn't find an example of such as query in the latest Django docs. For reference, the example shown in the linked answer is as follows: SELECT * FROM t; ┌────────┬────────┐ │ f1 │ f2 │ ├────────┼────────┤ │ (null) │ 1 │ │ 2 │ (null) │ │ (null) │ (null) │ │ 3 │ 4 │ └────────┴────────┘ (4 rows) SELECT * FROM t WHERE NOT (t IS NOT NULL); ┌────────┬────────┐ │ f1 │ f2 │ ├────────┼────────┤ │ (null) │ 1 │ │ 2 │ (null) │ │ (null) │ (null) │ └────────┴────────┘ (3 rows) -
Django upload files with with AJAX
I am uploading multiply files on backend with AJAX. How can I select file object from input? And how can I create AJAX request? var files = $('#filefield').prop('files'); Is it right? My ajax request: $.ajax({ url: '/tracks/', data: JSON.stringify(files), headers: { 'X-CSRFToken': $.cookie("csrftoken"), 'Content-Type':'application/json' }, cache: false, contentType: false, processData: false, method: 'POST', success: function(data){ alert(data); } Thanks for answers! -
Does anyone give me an example of implementing chain of responsibilities patterns inside Django framework? [closed]
I need to implement event that triggers series of activities in a sequential manner inside Django framework. -
Django Form DateInput with widget in update: loosing the initial value
I need a DateInput field in a ModelForm with the default HTML datepicker (I'm not using 3rd party libraries). Since the DateInput is rendered with <input type = "text"> by default, the datepicker is missing (it comes for free with <input type = "date">) I've found some examples explaining how to change the input type by handling widget parameters (below the code I've done so far) The issue I have the datepicker working correctly but in "update mode" when passing initial date value to the form (see view part), the date remains empty in the HTML. I've tried to find the cause and it seems that the 'type': 'date' part in the widget customization is clearing the initial value is some way; in fact, removing it, the initial value date is displayed again, but I loose the datepicker of course. In the view the date is passed with a valid value I also found another similar unanswered question where the field was declared as class DateInput(forms.DateInput): input_type = 'date' date_effet = forms.DateField(widget=forms.DateInput(format='%d-%m-%Y'), label='Date effet') the problem still remains My code model.py class TimesheetItem(models.Model): date = models.DateField() description = models.CharField(max_length=100) # many other fields here form.py class TimesheetItemForm(forms.ModelForm): def __init__(self, *args, … -
loading css with block in Django
I'm trying to load block for CSS in Django. However for some reason it doesn't work. my template : {% extends 'main/base.html' %} {% load static %} {% block css %} <link rel="stylesheet" href="{% static 'main/style.css' %}"> {% endblock %} {% block title %}Some Title{% endblock %} {% block content %} Some Content {% endblock %} And below is the upper part of base.html file {% load static %} <!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- This line below is the base styling, whereas the css file I'm trying to load is a specific styling for a specific page. --> <link rel="stylesheet" href="{% static 'base.css' %}"> {% block css %} {% endblock %} <title>{% block title %}{% endblock %}</title> </head> I have the right css file at the right directory, but it is not reflected at all. I don't see what I've done wrong. I would very much appreciate your help. :) -
Jquery not sending correct item id in Django
I'm trying to send some form data in django via ajax. the data i'm sending is the item id of objects. But when i'm making the ajax call it is not sending the correct item id. sometimes it is sending the id of the first item only. views.py def contact(request): msg = Message.objects.all() if request.POST.get('action')=="post": idi = request.POST.get('id') print(idi) ms = Message.objects.get(id = idi) print(ms) return render(request, "dashboard/contact.html", {"msg": msg, "ms": ms}) return render(request, "dashboard/contact.html", {"msg": msg}) ajax $(function() { // Remove button click $(document).on( 'click', '.ida', function(e) { e.preventDefault(); var pk = $(this).attr('value') $.ajax({ type: "POST", url: '{% url "contact" %}', data: { id: pk, csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val(), action: "post", }, success:function(){ console.log(pk) } }); }); }); form <form> {% csrf_token %} <input type="hidden" name="id" value="{{m.id}}" id="id"> <button type="button" class="btn btn-success ida" data-toggle="modal" data-target="#exampleModal">View</button> </form> Thanks in advance. -
With Django, can I reset primary key of all existing records?
Say I have a model Client: class Client(models.Model): name = ... address = ... And I imported a list of 1000+ clients to the model, with django-import-export. It worked like a charm. However, the ids (primary key) of the records aren't start from 1. It seems that by importing the clients, ids from 1 to 1000+ are used by django-import-export, and the imported client instances using id from 1000+. No harm but not beautiful. So is it possible to reset all the records' ids from 1? Does sqlsequencereset work in this situation? -
Django Rest Framework + Django CAS
I've been tasked with adding CAS authentication to an existing Django app which uses the Django Rest Framework. Using django-cas library I'm able to authenticate via CAS to the admin features of the Django framework, but I'm not sure how to go about authenticating the Django rest framework app via CAS; it's still authenticating via some custom authentication logic that the original developers added. If anyone has any insight or experience with this it would be much appreciated. -
Django model React
I'm trying some Django + React stuff and I'm a bit confused with the particular role of Django model in this scheme. As I can understand Django model provide smooth way to create some typical forms by users of the site (please correct me). And I can't feel the edge of what should be hardcoded and what I need to store in model. In case of React (I'm trying to connect react with django through api via djangorestframework) should I create a model for Header? And store bg image with it and my slogans. I feel it's should be purely in frontend. But next section with 3 typical screens (they will be listed horizontally and swap each other). They are just copy of each other with different data (title, bg, fg, text, link), for me it seems closer to model usage. But model initially empty and if I want to get this data from model I firstly need to somehow store this data to model. ofc I searched this info widely but so far can't create clear understanding by myself. Thanks )