Questions tagged as 'django'

2
answers

Get logged in to Django globally

All my models have relationship with User , and by default all my query_set will be made based on the user logged into the system. How would you do to get the user logged into any area of the app, for example the model , why will...
asked by 26.04.2017 / 19:25
1
answer

How to create a form and authenticate Django user

Good night everyone. I'm developing a project in django just for educational purposes and I could not find a solution to my problem. I could not generate a form for the user to log in, much less authenticate this user. I've already been...
asked by 26.02.2017 / 04:01
1
answer

Doubt with parameter

I'm watching a video of python but I do not understand one thing. I have the file utils.py def code_generator(size=6, chars=string.ascii_lowercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) def create...
asked by 01.12.2016 / 16:17
2
answers

How to differentiate variable (inputs) in the same Django form

Good morning! I have the following question: I have a Person class, of which I can have 3 types of person (Victim, Aggressor and Witness) in the same form ... how would I do to set the variables so that when saving to the bank are 3 different...
asked by 12.05.2016 / 16:43
2
answers

Unknown command: 'syncdb' Visual Studio 2013

I'm having a hard time developing a system in Django. When I try to sync the database, this error appears: Python interactive window. Type $help for a list of commands. Executing manage.py syncdb Unknown command: 'syncdb' Type 'manage.py help'...
asked by 13.12.2015 / 20:28
1
answer

How do I assign a class to a field type in Django?

I'm trying to find out which field is a DateField and thereby assign a class='date' . How do I get the field type? The following code does not work but displays the logic: class MeuForm(forms.ModelForm): ... def __init_...
asked by 21.03.2015 / 20:52
1
answer

TypeError with calculated field (Django)

TypeError with calculated field unsupported operand type(s) for *: 'int' and 'NoneType' error in the return line below models.py def get_subtotal(self): return self.price_sale * self.quantity subtotal = property(get_subtotal) a...
asked by 02.07.2015 / 15:42
1
answer

What is the best way to organize views in Django?

I have views.py in my study project where I group it from methods to represent views (methods that return HttpResponse), to generic class-based views (such as DetailView, ListView). I was thinking: what are the best practices for organizing v...
asked by 06.02.2015 / 00:52
1
answer

Editing tables, DateField field

In one of the insert's of my application, I have a DateField field, At first there is no error when saving the dates in the database ( SQLite3 ), I I report a date in the format DD/MM/AAAA , and it is saved in the format AAAA/MM/DD...
asked by 14.07.2014 / 03:43
1
answer

How to use Template Inheritance to inherit Style Sheets (css) in my Django project?

I have a base.html template and another template library.html that is inheriting base! I have inherited most of base.html, but when I try to add another link tag in the Style block Django accuses TemplateSyntaxError error, when I remove the bloc...
asked by 12.05.2014 / 20:16