Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Change form styling of django-filters from SelectMultiple to CheckboxInput¶
I feel that the documentation is quite unclear on this. I have the following filter logic on an attribute called categories of model ProductPage (works as intended): class ProductFilter(django_filters.FilterSet): class Meta: model = ProductPage fields = ['categories'] def product_list(request): f = ProductFilter(request.GET, queryset=ProductPage.objects.all()) return render(request, 'product/filter.html', {'filter': f}) Template looks like this: <form method="get"> {{ filter.form }} <div class="fieldWrapper"> {{ filter.form.name.errors }} {{ filter.form.name }} </div> <input type="submit" /> </form> I get the typically Multiple Select form which technically works well: Picture of form However, I would rather have a few checkboxes / radio buttons / something similar. Yet, I have no idea where to get access to the styling or type of widget. -
'widget_tweaks' to style the formset.empty_form
Does anyone know how I can use 'widget_tweaks' to style the formset.empty_form. Check the documentation however when applying it I get this error: the object 'PartForm' does not have attribute 'as_widget' I think i'm not doing well in html. I already used widget_forms on the same page and it looks good; but when implementing it in empty_forms it doesn't work presupuestos-forms.html <div class="form-row" id="empty-row"> {{formset.empty_form|add_class:"form-row" }} </div> -
How to Logout the App when Refresh the page ? In Django
This Is My code of login in Django Application from django.shortcuts import redirect, render from django.contrib.auth import authenticate,logout,login from django.contrib.auth.decorators import login_required from SedHelper.settings import LOGIN_URL from .models import HelperApps # Create your views here. def Login(request): if request.method == 'GET': if request.user.is_authenticated: logout(request) return render(request,'login.html') elif request.method == 'POST': username=request.POST['username'] password=request.POST['password'] user = authenticate(username=username, password=password) if user is not None: login(request, user) return redirect(home) else: error={ 'LoginSts':False, 'MSG':'You are not Logged In' } return render(request,'login.html',context=error) # No backend authenticated the credentials def logout_view(request): print(request.user.is_authenticated) if request.user.is_authenticated: logout(request) return redirect(Login) def home(request): #load all data from db(10) if request.user.is_authenticated: posts=HelperApps.objects.all()[:11] return render(request,'dashboard.html',{'posts':posts}) else:return redirect(Login) I just wanted to Logout when ever someone refresh the Page .In entire Application where ever someone refresh the the page it should logout immidiately.Anyone please. i am also new to stackoverflow Please try to ignore the mistakes. -
TypeError: __init__ missing 1 required positional argument: 'to', I get this error when I make migrations "python3 manage.py makemigrations"
Python 3.8.10, django version 3.2.9. When I am running the following code: "python3 manage.py makemigrations auth_app" ... I get this error: TypeError: init() missing 1 required positional argument: 'to'. I've checked out everything that says the error and still get the same.This is the whole error message. Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/allfsr/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/home/allfsr/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute django.setup() File "/home/allfsr/.local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/allfsr/.local/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/allfsr/.local/lib/python3.8/site-packages/django/apps/config.py", line 301, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 848, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/__init__.py", line 1, in <module> from .account import Account File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/account.py", line 4, in <module> class Account(models.Model): File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/account.py", line 6, in Account user = models.ForeignKey(related_name='account', on_delete= models.CASCADE) TypeError: __init__() missing 1 required positional argument: 'to' -
django jQuery date picker wont change date format
I have a django form which as two date fields. I am trying to have a Calendar Pop-up with the default date being sent on click as ("yyyy-mm-dd"). I have tried this several ways, changed the setting in the javascript, changed the django settings file, but no matter what the form says invalid date and the date format that gets sent to the field always is mm/dd/yyyy. Here is an example of the code In the form I have: from django import forms from functools import partial DateInput = partial(forms.DateInput, {'class': 'datepicker'}) class SearchForm(forms.Form): start_date = forms.DateField(widget=DateInput(format = '%Y-%m-%d'), required=False, input_formats=['%Y-%m-%d']) end_date = forms.DateField(widget=DateInput(format = '%Y-%m-%d'), required=False, input_formats=['%Y-%m-%d']) My tempplate has the following: <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script> <script> $(document).ready(function() { $('.datepicker').datepicker() }); </script> <TR> <TD COLSPAN="3" ALIGN="Center"> Start Date:&nbsp;{{ form.start_date }}&nbsp;&nbsp; End Date:&nbsp;{{ form.end_date }} Date Format <B>MUST</B> be YYYY-MM-DD<br> Dates are inclusive.<br> If a date is left blank it is assumed to go until the start or end.</TD> </TR> I have tried putting dateFormat('yyyy-mm-dd') inside the datepicker code , as well as format('yyyy-mm-dd'), format('yy-mm-dd'). None of them changes the way to date is sent to the field, it's always "mm/dd/yyyy'. The form says this is not … -
I need to create an authentication for a distributor using jwt
I need to create an authentication for a distributor using jwt. However I'm only able to create the authentication token for the superuser. Could someone help me create a way to authenticate the distributor? Here are the models: class Distributors(TimeStampedModel): name = models.CharField("Nome completo", max_length=250) cpf = BRCPFField("CPF") email = models.EmailField("Email") password = models.CharField("Senha", max_length=15) def __str__(self): return self.name authentication needs to ask for name and password -
How to get data from amoCRM through API?
I am trying to get data through API from amoCRM system but I am having some problems and I am really tired. The url: https://alamiri.amocrm.ru/api/v4/contacts This API should return contacts of users that contain (first name, email, number, ...). When I copy and paste the above link in the browser, I get the data and everything works fine but when I try to get that data in Python it returns the following: {'detail': 'Invalid user name or password', 'status': 401, 'title': 'Unauthorized', 'type': 'https://httpstatus.es/401' } my code in python (Django framework): import requests import pprint def get_contacts(): url = "https://alamiri.amocrm.com/api/v4/contacts" api_key = "def50200c1f820b24e23a1a776cec978ed0e3eb3c479b83b91bef4158728d" client_uuid = "e1899afa-85a8-45ca-93f9-7f4b26374a5d" client_secret = "jUlw4E6H4jIW39GXXjpLjratAwOEiaqPr3KDBKYwc9ZQLXK2UlhMcsuu" headers = { 'login': login, 'client_uuid': client_uuid, 'client_id': client_uuid, 'client_secret': client_secret, 'grant_type': 'authorization_code', 'Authorization': f'Bearer {api_key}', } response = requests.get(url, headers=headers) pprint.pprint(response.json()) get_contacts() I am reading their documentation (amoCRM) and I tried a lot of things but none worked! 😥 https://www.amocrm.com/developers/content/platform/abilities/ I followed their instructions how to work with their API: https://nova-amocrm.notion.site/894277ffef5940e7a5daadd2abc746c8 But I am stuck and I don't know how to solve this problem! Any help please? If you don't know what is amoCRM, then -
Show ValidationError in the template - Django
I am developing a program that consists of sales. I want that when registering a sale, if there is not enough stock of the requested product, an error will appear indicating that there is no stock. I was able to do it but I get the ValidationError like this: ValidationError at /ventas/create/ ['No hay suficiente stock del producto.'] forms.py: class VentasForm(forms.ModelForm): """Formulario modelo de ventas.""" class Meta: """Meta class.""" model = Venta fields = ('fecha', 'cliente', 'producto', 'cantidad', 'forma_pago') def save(self): """Restar stock.""" data = super().clean() producto = Product.objects.get(id=data['producto'].pk) verificar_stock = producto.cantidad - float(data['cantidad']) if verificar_stock >= 0: producto.cantidad -= float(self.data['cantidad']) else: raise forms.ValidationError('No hay suficiente stock del producto.') producto.save() views.py: class CreateVentasView(CreateView): """Registrar venta.""" template_name = 'ventas/create.html' form_class = VentasForm success_url = reverse_lazy('ventas:list') context_object_name = 'venta' and in the template: {{ form.as_p }} -
Django Crispy Form loop through {% crispy %} object
I'm trying to use crispy form fields within each table's column. I can render it using: {% load crispy_forms_tags %} <tr> <form method="get" class="form-inline justify-content-center"> {% for field in filter.form %} <th>{{ field|as_crispy_field }}</th> {% endfor %} <input class='hidden-submit' type="submit"/> </form> </tr> And it looks like this which is what I want: But the problem is my Layout() which I'm using to add extra parameters such has placeholders etc to the form is not working because I'm using |as_crispy_field tag to render individual fields. Here is my form component: class CustomFiltersForm(forms.Form): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_show_labels = False self.helper.form_tag = False self.helper.layout = Layout( ) for field_name, field in self.fields.items(): self.helper.layout.append(Field(field_name, placeholder="Search " + field.label)) Is there a way to loop through {% crispy filter.form %} or an alternative way to populate individual fields using cripsy forms? Something like: {% for field in {% crispy filter.form%} %} ... {% endfor %} -
Condition whether field A or B is required in Django Rest Framework
I have a serializer in which I would like to give the opportunity to send a NEW address with a POST request OR give an ID of an already existing address. One of both is required, but right now it asks for both to be given. Any possibility to achieve that it validates with a condition? class OrderSerializer(serializers.ModelSerializer): class Meta: model = Order #fields = '__all__' exclude = ['in_calculation','canceled',] address = AdressSerializer() addressid = serializers.CharField(source='address') read_only_fields = ['id','user','status','costs',''] -
When are Django Querysets executed in the view?
I read the Querysets Django docs regarding querysets being lazy, but still am a bit confused here. So in my view, I set a queryset to a variable like so players = Players.objects.filter(team=team) Later on, I have a sorting mechanism that I can apply sort = '-player_last_name' if pts > 20: players = players.filter(pts__gte = pts).order_by(sort) else: players = players.filter(pts__lte = pts).order_by(sort) if ast < 5: players = players.filter(asts__lte = ast).order_by(sort) else: players = players.filter(asts__gte = ast).order_by(sort) context = {players: players) return render(request, '2021-2022/allstars.html', context) What I want to know is, when is the players queryset evaluated? is it when each page is rendered, or everytime I assign the queryset to a variable? Because if it's the former, then I can just apply the .order_by(sort) chain and the previous applications are redundant. -
What is the best way to learn Django?
What is the best way to learn Django? -
Saving values to django model through a for loop
I want to use a dictionary to store values in a model through a modelform and a view. Today I solve it like this: form.variable_1 = dictionary['variable_1'] form.variable_2 = dictionary['variable_2'] form.variable_3 = dictionary['variable_3'] form.variable_4 = dictionary['variable_4'] form.variable_5 = dictionary['variable_5'] form.variable_6 = dictionary['variable_6'] The keys in the dictionary are identical to the field names for the values I want to store. I would like to make the function a bit more pythonic - something like this: for field in form: form.field = dictionary['field'] However, I'm not sure how to use the Django ORM to achieve this. The fields I want to iterate are numbered 3-28 in the list of fields, so I guess I would have to slice the fields somehow and create a list based on that? -
foreach in javascript menutoggle should be active in the icon I clicked in only
I hope you are doing well, I am using django, problem is I have a list of items that contains a menuToggle my code is like this <!--here is code .... --> <div class="container"> {% ifequal request.user.username obj.author.user.username %} <div class="action1"> <div class="icon" onclick="menuToggle1();"> <img src="{% static 'images/ore.svg'%}" class="svg"> </div> <div class="menupost" id="menupost"> <ul> <li><i class="fa fa-refresh" aria-hidden="true" style="margin-right:10px;"></i><a href="{% url ''%}">Update</a></li> <li><i class="fa fa-trash-o" aria-hidden="true" style="margin-right:10px;"></i><a href="{% url ''%}">Delete</a></li> </ul> </div> </div> <h2 id="title" class="title">{{obj.title}}</h2> <!--and so on...--> </div> <script> function menuToggle1(){ document.querySelectorAll('.menupost').forEach(function(element) { element.classList.toggle('active'); }); }; </script> so when I click on one of them , I see all the menu of all items. so I don't want to see all menutoggle when I click on just one of them.I think you understand my question, I hope you guys can help me. -
problem getting filterset data originating from a MultipleChoiceFilter
Let's say I have the following FilterSet: class ReportFilter(django_filters.FilterSet): type = django_filters.MultipleChoiceFilter(field_name="type", lookup_expr='exact') ... and Client submits the following request: www.exmaple.com/reports/?type=1&type=2 I want to be able to get the filterset data from the multiple choice filter as a list, i.e. do something like this: class ReportFilter(django_filters.FilterSet): ... def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) types = self.data["type"] I would expect types to give me a list [1, 2] but instead I am getting a string 2. The strange this is that if I print self.data of the filterset, it displays what I am expecting to see <QueryDict: {'type': ['1', '2']}> Any thoughts about what I am doing wrong here? -
Django Models - How to tell if an entry is being updated vs a new entry being inserted?
For one of my models I am using, there is some conditional logic that occurs, and part of what I need to know is if an entry is being made for the first time, or if it's updating an existing model. My Model is below, I will follow it with an example of what I am needing. Shipment Model class Shipment(models.Model): CARRIER_CHOICES = [ ('GW', 'Greatwide'), ('SM', 'Sample'), ] dateTendered = models.DateField(default=date.today) loadNumber = models.CharField(max_length=50) masterBolNumber = models.CharField(max_length=50) carrier = models.CharField(max_length=100, blank=True, choices=CARRIER_CHOICES, default='GW') destinationCity = models.CharField(max_length=70) destinationState = models.CharField(max_length=50) rateLineHaul = models.DecimalField(max_digits=15, decimal_places=2) rateFSC = models.DecimalField(max_digits=15, decimal_places=2) rateExtras = models.DecimalField(max_digits=15, decimal_places=2, default=0.00) rateTotal = models.DecimalField(max_digits=15, decimal_places=2, blank=True, null=True, default=0.00) loadDelivered = models.BooleanField(default=False) customCarrierRate = models.BooleanField(default=False) deliveryDate = models.DateField(null=True, blank=True) deliveryTime = models.TimeField(null=True, blank=True) driverName = models.CharField(max_length=70, null=True, blank=True) driverCell = models.CharField(max_length=70, null=True, blank=True) rateTotalCarrier = models.DecimalField(max_digits=15, decimal_places=2, null=True, default=0) shipmentMargin = models.DecimalField(max_digits=15, decimal_places=2, null=True, blank=True) shipmentMarginPercentage = models.DecimalField(max_digits=15, decimal_places=3, null=True, blank=True) trailer = models.ForeignKey(Trailer, on_delete=models.PROTECT, blank=True, null=True) id = models.UUIDField(default=uuid.uuid4, unique=True, primary_key=True, editable=False) Here are some examples of why I need to differentiate between an update or an insert. Possible Scenarios When Adding a Shipment a. Only required fields are entered. Then the following happens 1a. Calculate rateTotal 1b. … -
Django: Import data from uploaded excel file
I'm trying to create an app to import thanks to an uploaded .csv file data to my database. This is where I've managed to arrive by myself: my file is uploaded without problems and I can pass the information from the file to the variable first_row and second row. My problem now is how I can save the information in the database. My views code: VIEWS @login_required def file_upload(request): data = None if request.method == 'POST': file_form = FileForm(request.POST, request.FILES) data_form = DatasetForm(request.POST, request.FILES) raw_file= request.FILES if file_form.is_valid() or data_form.is_valid(): data = request.FILES['file_upload'] data = pd.read_csv(data, header=0, encoding="UTF-8") first_row = data.iloc[[0]] second_row = data.iloc[[1]] file_form.instance.user = request.user.profile file_form.instance.filename = raw_file['file_upload'].name file_form.save() return redirect('upload_file') else: return redirect('home') else: form = FileForm() context = { 'data': data, 'second_row': second_row, 'file_form': file_form, 'message': message, } return render(request, 'upload_file.html', context) These are how my data and models looks: DATA code tot sd name_1 aa 3 1 name_2 bb 7 2 MODEL class File(models.Model): user = models.ForeignKey(Profile, on_delete=models.CASCADE) filename = models.CharField(max_length=250) file_upload = models.FileField(upload_to=path) upload_date = models.DateField(default=datetime.now) def __str__(self): return self.user.name + 'file' class Dataset(models.Model): user = models.ForeignKey(Profile, on_delete=models.CASCADE) file_uploaded = models.OneToOneField(File, on_delete=models.CASCADE) name_user_A = models.CharField(max_length=250) code_user_A = models.PositiveIntegerField(null=True) total_user_A = models.PositiveIntegerField(null=True) sd_user_A = models.PositiveIntegerField(null=True) … -
Django custom authentication class is not reading AllowAny
Here is the REST authentication class: def get_authorization_header(request): raw_token = request.COOKIES.get('auth_token', ) or None auth = request.META.get('HTTP_AUTHORIZATION', ) if isinstance(auth, str): auth = auth.encode(HTTP_HEADER_ENCODING) return auth class JWTAuthentication(BaseAuthentication): keyword = 'auth_token' def authenticate(self, request): raw_token = request.COOKIES.get('auth_token', ) or None if raw_token is None: return None return self.authenticate_credentials(raw_token) def authenticate_credentials(self, key): try: user_model = get_user_model() payload = jwt.decode(key, settings.SECRET_KEY, algorithms="HS256") user = user_model.objects.get(email=payload['email']) except (jwt.DecodeError, user_model.DoesNotExist): raise exceptions.ParseError('Invalid token') except jwt.ExpiredSignatureError: raise exceptions.ParseError('Token has expired') if not user.is_active: raise exceptions.AuthenticationFailed('User inactive or deleted') return (user, payload) def authenticate_header(self, request): return self.keyword And here is the view: class GoogleLogin(APIView): permission_classes = [AllowAny] def post(self, request): data = request.data response = Response() token = data.get('tokenId', None) if not token: raise exceptions.AuthenticationFailed('No credentials provided.') try: token_info = id_token.verify_oauth2_token(token, requests.Request(), google_app_id) email = token_info['email'] user = authenticate(email) if not user: serializer = RegisterSerializer(data={'email': token_info['email'], 'first_name': token_info['given_name'], 'last_name': token_info['family_name']}) serializer.is_valid(raise_exception=True) serializer.save() jwt_token = gen_token(email) response.set_cookie( key='auth_token', value=jwt_token, expires=datetime.datetime.utcnow() + datetime.timedelta(days=30), secure=False, httponly=True, samesite='Lax' ) return response except ValueError: return Response('Invalid TokenId.', status=status.HTTP_400_BAD_REQUEST) I'm trying to implement Google social login where the frontend (ReactJS) sends tokenId to the backend (Django) to verify the token then returns a response with a JWT token stored in the cookies … -
How to get user object in template?
model.py class User(AbstractUser): is_agree = models.CharField(max_length=1, blank=True) is_verify = models.CharField(max_length=1, blank=True) type = models.CharField(max_length=1, blank=True) name = models.CharField(max_length=255, blank=True) address1 = models.CharField(max_length=255, blank=True) address2 = models.CharField(max_length=255, blank=True) bank_account = models.CharField(max_length=255, blank=True) phone_number = models.CharField(max_length=255, blank=True) I want to get users type in template. I tried {{ user.type }}. but was not worked -
Django declare subquery for re-use?
Is there a way to store a subquery in django the same way SQL DELCARE works? I've got multiple calculations using subqueries. I then reference these subqueries in further calculations. Problem is, once these subqueries are referenced, they "run again" and call another huge select query unnecessarily. Is there a way to call the query once then re use? Only stipulation is that this needs to be done in a single query using annotations. -
Why we use axios PUT method when we can use POST method that does the same job
I'm using axios in a REACT / Django project, the question that I didn't find an answer to is, Considering we can update a databate table, by first sending data with POST method from react to django view then django update the database table with .update function using the data in POST method... Then why we use PUT method or DELETE method ? Thank you -
How to disable sorting by multiple columns in Django Admin?
How can I disable sorting by multiple columns in Django Admin? I'd like to simplify sorting to only one column at a time. Currently, if you click on a column header, this column is added to the sorting order. I.e. http://localhost:8000/admin/core/user/?o=-2.5.3.1, where o query parameter determines the sort (see numbers 4, 1, 3 on the attached image) -
Python Django Async Def work with objects
I have this code in my Django Channels Consumer. async def connect(self): from .models import Chat, Menu from client.models import ChannelCommunication, VirtualAgent self.agents = await sync_to_async(VirtualAgent.objects.get, thread_sensitive=True)(pk=1) self.channel = await sync_to_async(ChannelCommunication.objects.get, thread_sensitive=True)(virtual_agent=agents.pk) self.chat = Chat() self.chat.channel = self.channel self.chat.menu_nav = await sync_to_async(Menu.objects.get(id=self.agents.flow_start)) await database_sync_to_async(self.chat.save)() self.menu_nav = self.chat.menu_nav # Join room group await self.channel_layer.group_add( self.general, self.channel_name ) await self.accept() And have error bellow: 2021-11-19 14:28:35,051 ERROR Exception inside application: You cannot call this from an async context - use a thread or sync_to_async. Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 173, in get rel_obj = self.field.get_cached_value(instance) File "/usr/local/lib/python3.8/site-packages/django/db/models/fields/mixins.py", line 15, in get_cached_value return instance._state.fields_cache[cache_name] KeyError: 'flow_start' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/channels/routing.py", line 71, in call return await application(scope, receive, send) File "/usr/local/lib/python3.8/site-packages/channels/sessions.py", line 47, in call return await self.inner(dict(scope, cookies=cookies), receive, send) File "/usr/local/lib/python3.8/site-packages/channels/sessions.py", line 263, in call return await self.inner(wrapper.scope, receive, wrapper.send) File "/usr/local/lib/python3.8/site-packages/channels/auth.py", line 185, in call return await super().__call__(scope, receive, send) File "/usr/local/lib/python3.8/site-packages/channels/middleware.py", line 26, in call return await self.inner(scope, receive, send) File "/usr/local/lib/python3.8/site-packages/channels/routing.py", line 150, in call return await application( File "/usr/local/lib/python3.8/site-packages/channels/consumer.py", line 94, in app return await consumer(scope, receive, send) File "/usr/local/lib/python3.8/site-packages/channels/consumer.py", line 58, … -
Adapt Django model (with djOngo) to MongoDB document
I have full database with documents like: { "_id": { "$oid": "6191419b42a21c7b38f028ae" }, "like_count": 58142, "slug": "the-elder-scrolls-iv-oblivion", "name": "The Elder Scrolls IV: Oblivion", "description": "The Elder Scrolls IV: Oblivion", "image": { "thumb": "https://cdn.website.com/c/04dcf5be7b651ef57c542bf5634b08c2/400x510/cdn.kanobu.ru/games/e17c468f-cd9e-48d7-bb23-6cbd736fa330.JPG", "origin": "https://cdn.website.com/games/e17c468f-cd9e-48d7-bb23-6cbd736fa330.JPG" }, "release_date": { "string": "20 марта 2006", "date": "2006-03-20", "is_precise": true, "precision_class": "day" }, "created": "2009-03-02T18:48:27", "rating": 8.94065934065934, "genres": [{ "id": 3649, "name": "Экшен", "slug": "action", "position": 10 }, { "id": 3656, "name": "Ролевые", "slug": "rpg", "position": 30 }], "platforms": [{ "id": 1, "name": "PC", "slug": "pc", "position": 0 }, { "id": 59, "name": "Xbox One", "slug": "xbox-one", "position": 2 }, { "id": 4, "name": "PlayStation 3", "slug": "ps-3", "position": 4 }, { "id": 6, "name": "Xbox 360", "slug": "xbox-360", "position": 5 }], "developers": [{ "id": 79, "name": "Bethesda Softworks", "slug": "bethesda-softworks" }], "publishers": [{ "id": 43, "name": "2K Games", "slug": "2k-games" }], "requirements": { "min_os": "Windows XP, Windows 2000, Windows XP 64-разрядная", "min_cpu": "Intel Pentium 4 с тактовой частотой 2 ГГц или аналогичный ", "min_gpu": "со 128 МБ видеопамяти, совместимая с DirectX 9.0 ", "min_ram": "1.0", "min_hdd": "5.0", "rec_os": "", "rec_cpu": "", "rec_gpu": "", "rec_ram": null, "rec_hdd": null } } I used CharField for fields like "name", "description", and EmbededField (from Djongo) for fields … -
Difference between web application architecture and design pattern?
I need to develop a photo album web app in Django, stored on cloud services, with user login authentication, metadata and database. It must be developed according to a specific software design pattern that is different to the architectural pattern chosen. Please explain the difference between design and architectural patterns. Any industry acceptable suggestions on these patterns, suitable for a small project as explained above, would be very helpful.