Pablo
☺️
Josias
hey, can someone explain to me how I can have 2 different forms in the same view
Josias
I tried but give me errors, I want that i Post the info only validate and save the form that i filled
Mike
I have 2 models. Level and Question. I would like to add new somethig using slug in django shell. I can add Question.objects.create(level_id=10, english_name='new something') it works . But I want to add using slug. For example something like that : Question.objects.create(level_slug='first-level', english_name='new something'). But I am getting error TypeError: Question() got an unexpected keyword argument 'level_slug'. How can I fix it?
Mike
This is my models.py class Level(models.Model): level = models.CharField(max_length=100, unique=True) created = models.DateTimeField(auto_now_add=True) slug = models.SlugField(max_length=100, unique=True, null=True, blank=True) #class Meta: #ordering = ['level'] def __str__(self): return self.slug #return '{}, {}'.format(self.slug, str(self.level))
Mike
class Question(models.Model): level = models.ForeignKey(Level, related_name="question", on_delete=models.CASCADE) english_name = models.CharField(max_length=350, null=True, blank=True) russian_name = models.CharField(max_length=350, null=True, blank=True) buttons = models.TextField() def __str__(self): return self.english_name #return '{}, {}'.format(level, english_name)
AFOLABI
Check your code, something is missing, use pastebin
I have decide to use the User instead of form from model and it works fine now, just wondering how to extend User
Anonymous
I tried but give me errors, I want that i Post the info only validate and save the form that i filled
Just send the button along with ur post request and check for it in ur views.py
Ghorz
if anyone has a reliable link, much appreciated. i'll start browsing now anyways he
The first time I integrated adminLte.io with Django, I was a newbie but I did not need someone to tell me that all I need to do was separate the static and templates, then create a base.html, it's all instinct, you have it, put it to use.
Ghorz
I have decide to use the User instead of form from model and it works fine now, just wondering how to extend User
https://ghorz.com/blog/Tutorial/2019-08-22/5/how-to-create-django-custom-user-model-using-django/
Денис
class Question(models.Model): level = models.ForeignKey(Level, related_name="question", on_delete=models.CASCADE) english_name = models.CharField(max_length=350, null=True, blank=True) russian_name = models.CharField(max_length=350, null=True, blank=True) buttons = models.TextField() def __str__(self): return self.english_name #return '{}, {}'.format(level, english_name)
There are some things that concern me in this code. First: related_name in ForeignKey is recommended to be in plural, say, 'questions', because this is OneToMany relationship. Second: english_name and russian_name is a redundancy for a database. You should probably use Django's internationalization mechanics instead, translating the data in views according to current user's language. This is described in docs. And third: what's the purpose of buttons? If this is a list of something, you might probably create a separate model and relate it to Question via ManyToManyField.
Anonymous
any devloper from ahmedabad,gujrat,india
Anonymous
i need supprot for m,y first project
Anonymous
Need help in rest API login
m0nte cr1st0
Help pls https://stackoverflow.com/questions/58317948/how-to-run-a-group-of-celery-tasks-apps-arent-loaded-yet
Дмитрий
Help me please. I have model shop with open, close time fields how can i get http responce with 1 if now its open and 0 if closed?
Дмитрий
yes time check by current time
Денис
Help me please. I have model shop with open, close time fields how can i get http responce with 1 if now its open and 0 if closed?
DateTimeField is generally a datetime instance, so you can take datetime.now() and check if its time is between your start and end
Денис
thx man )
datetime objects comparison is not what i can help you with and not a Django-related question as well
Денис
but nevermind
Дмитрий
i need just so get serializers related with datetime.now() in range open - close then True
Дмитрий
as i see it
Денис
probably. I can't dig into it right now
Дмитрий
i got it already no problem thx anyway )
Kannan
Hi guys,In django how to read outlook emails? If anyone knows share
Kumar
Hi, plz tell me the advantages and disadvantages of using sqlite in django
inchidi
Hi, plz tell me the advantages and disadvantages of using sqlite in django
one advantage is you dont need to install anything
Nikhil
I am new to django...how should I start
Nikhil
Help please
inchidi
Anonymous
Hi
Mirco
!rules
Doragonsureiyā
Read the rules before any activity: @PythonRules
Nikhil
Sorry
Mirco
no worries
Nikhil
Ohkk now my code is exactly like on newBoston when I give command of run server it says ==OS error(Winerror 123) the file name or directory or volume label syntax Is incorrect
Nikhil
What to do now
Nikhil
It also says something like <frozen importlib._bootstrap>
Nikhil
And when I give command of make migrations it says no module name - same as my app name
Mirco
Did u activate virtualenv ?
Nikhil
I thought pycharm already made virtual environment for me
Nikhil
Ohkk, I can do this thing 1) open pycharm 2) make virtual env 3) start new site and new all and then do coding part
Nikhil
Is that
Nikhil
Thank you for that... I have to install virtual env that worked
Mirco
😊
Sai
Getting stucked by celery in django. Logs are not showing bon terminal at specific time
Sai
How to automate the tasks ?
Mirco
Share your code 😁
Mirco
Use pastebin and similar
Mirco
Nope
Mirco
!rules
Doragonsureiyā
Read the rules before any activity: @PythonRules
Mirco
where's your custom model or ModelAdmin ?
Mirco
u also need the custom model
Jason
We need to register a receiver somewhere??
Денис
Tell me, how can I define a proper field ?
level_slug? You don't have it in your Question model. Define a level_slug as any field you like. Maybe even SlugField, I can't decide for you.
Mike
level_slug? You don't have it in your Question model. Define a level_slug as any field you like. Maybe even SlugField, I can't decide for you.
I am trying to create something using slug in django shell: Question.objects.create(level_slug='sport', english_name='football') But it doesn't work. Please look at that https://paste.ubuntu.com/p/2npMyPkJQR/
Денис
with a double underscore
Mike
Oh. I see now. Probably level__slug
one moment I will try right now
Денис
I am trying to create something using slug in django shell: Question.objects.create(level_slug='sport', english_name='football') But it doesn't work. Please look at that https://paste.ubuntu.com/p/2npMyPkJQR/
If you want a less risky way of such creation, do this: Create a Question object. Save it with question.save(commit=False) Then create a Level object, fill its fields. And do this: question.level = level_object And question.save()
Mike
Oh. I see now. Probably level__slug
Question.objects.create(level__slug='adoption', english_name='something new') TypeError: Question() got an unexpected keyword argument 'level__slug'
Mike
If you want a less risky way of such creation, do this: Create a Question object. Save it with question.save(commit=False) Then create a Level object, fill its fields. And do this: question.level = level_object And question.save()
I am doing correct? adoption = Level.objects.get(level='Adoption') # get something = Question(english_name='something') something.save(commit=False) And then I am getting :TypeError: save() got an unexpected keyword argument 'commit'
Денис
if you create your Level object beforehand, then you can save the Question without commit=False as your object doesn't need to wait for anything else.
Jason
How to save profile url to the custom user model in django rest auth.
Jason
There's a URLField for it
Yeah but how to trigger it just after signup?