Questions tagged [Django] (5086)

0
answer

How to withdraw dict in the template?

All well, there's this mixin resMIxin.py class ResourceMixin(object): def get_resource_info(self, uid, *args, **kwargs): #get count of all resources get_res = UserResource.objects.get(user_res_id=uid) stone_quant = get_res.user_stone tree_quant = get_res.user_tree steel_quant = get_res.user_steel # STONE stone_min...
lola asked April 19th 20 at 12:48
1
answer

Django urls — path() or url()?

Tell me, what is the difference between url() and path() to urls.py? What should I use?
Krystel asked April 19th 20 at 12:47
1
answer

As in django to filter the data in the alphabetical range?

there are buttons "a-g", "d-K", etc by clicking on them to filter the data?
Helena asked April 19th 20 at 12:46
2
answers

Django. Whether to allocate each model/view in a separate file?

Actually picking turnips on the Gita, I saw an example where instead of a single file models.py was the folder in which every model was in a separate file (and __init__.py that was the package). Actually in my opinion quite reasonable theme, according to people interested to know?
stan.Steuber61 asked April 19th 20 at 12:44
0
answer

Where are my media and static files when I use docker compose?

I use docker compose to deploy my django-nginx-gunicorn-postgres projects, despite the fact that I was able for the lessons to start and configure my projects, I have little understanding of many things. For example Where are my media and static files when I use docker compose? When I call docker-compose-f myproject.yml run...
Louie_Carter asked April 19th 20 at 12:42
1
answer

Django how to pass a variable to the template in admin?

How to pass gallery_add in the template? admin.py class Service_Admin(admin.ModelAdmin): save_as=True change_form_template = "admin_template.html" from django.db import connection with connection.cursor() as cursor: cursor.execute("SELECT * FROM some_table ") gallery_add = cursor.fetchall() admin_template.html: {% ex...
emmanuel asked April 19th 20 at 12:41
0
answer

Django Seems not out there looking for a template or an incorrectly written function, what to do?

In General, I tried to create my first website in Django(Django version 3.0.5 Python version 3.8.2). The course was quite outdated but all minor problems quickly resolved. Folder structure: mysite\ mainApp\ __pycache__ migrations\ __pycache__ mysite\ __pycache__ tamplates I started to do the main page from django.co...
Blair_Bashirian4 asked April 19th 20 at 12:37
0
answer

Django 2 How to reassign the widgets form fields, but the fields for different widgets?

There is a class in models.py class BarberCustomer(models.Model): "'A client name, service and time"' service = models.ForeignKey(BarberService, on_delete = models.SET_NULL, verbose_name='Name of service',blank=True, null=True, related_name='service_customer') #related_name need to display then comments on the detail page n...
skylar_Swift asked April 19th 20 at 12:35
0
answer

How to make so that the form can be used once?

There is a model: class Model(models.Model): . . . is_checked = models.BooleanField(default=False) And in the view: form = Form(request.POST or None) if request.method == 'POST': if form.is_valid: . . . form.save() How to make so that the form can only be used once?
Kaitlyn asked April 19th 20 at 12:34
1
answer

Zanazanyan display articles in a certain category?

views.py class LanguageDetailView(View): def get_queryset(self): return Post.objects.filter(to_display=True) def get(self, request, language_slug=None, slug=None): if language_slug is not None: post = self.get_queryset().filter(language__slug=language_slug) elif slug is not None: post = self.get_queryset().filter(ta...
Rebeca_Schamberg asked April 19th 20 at 12:27