These are chat archives for django/django

26th
Jan 2018
Anish Shrestha
@annshress
Jan 26 2018 09:27
need help with Timezone aware date time field
user enters datetime in his own timezone, which should be converted into UTC and stored in db. And again on retrieval should be shown in same users timezone.
which field-methods should I override to achieve it.
???
Prateek Dabas
@dprateek11
Jan 26 2018 10:16
hi everyone
just need a little help
Nick Ma
@ickma
Jan 26 2018 10:16
hi
Prateek Dabas
@dprateek11
Jan 26 2018 10:16
i have three tables in db
so do i have to make 3 app
Nick Ma
@ickma
Jan 26 2018 10:17
Why?
Prateek Dabas
@dprateek11
Jan 26 2018 10:17
or just define in models
i am a newbie
Nick Ma
@ickma
Jan 26 2018 10:18
1 app is enough
Why u think u need to make 3 apps?
Prateek Dabas
@dprateek11
Jan 26 2018 10:19
because there are 3 tables
Nick Ma
@ickma
Jan 26 2018 10:20
You can define 3 model classes in 1 app
Prateek Dabas
@dprateek11
Jan 26 2018 10:20
ok... Thank you
this is an example from my project,it is very very easy @dprateek11
Prateek Dabas
@dprateek11
Jan 26 2018 10:37
@ickma thank you
Lucas Garcia de Ara├║jo Martins
@lukasgarcya
Jan 26 2018 11:11

I have this form:

class Dashboard(forms.Form):
        year = forms.ChoiceField(choices=Year.objects.all().values_list('pk', 'year'))

and my test is not running because this error: django.db.utils.OperationalError: no such table: common_year

Prateek Dabas
@dprateek11
Jan 26 2018 11:33
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
as question is a foreignkey what are the parameters that has been provided
??
Prateek Dabas
@dprateek11
Jan 26 2018 12:07
hi anyone online?
Mir Nazim
@mnazim
Jan 26 2018 12:08
@dprateek11 did you read/implement the django official polls tutorial?
If not you must do that first.
Prateek Dabas
@dprateek11
Jan 26 2018 12:09
@mnazim ok
@mnazim i want to ask one more thing
Mir Nazim
@mnazim
Jan 26 2018 12:09
ask
@mnazim please check the above link
and please tell me how to link foreignkey
i am getting this error name Rooms is not defined
Mir Nazim
@mnazim
Jan 26 2018 12:12
Rooms is undefined because it's being using before being defined. Put quotes around it 'Room.
Ghost
@ghost~56fc9ded85d51f252abbbbad
Jan 26 2018 12:13
maybe you have to define Rooms before ?
alright
also, room_price, integer?
Mir Nazim
@mnazim
Jan 26 2018 12:13
Also use singular form for Model names. Model instance represents a single row in the table
Prateek Dabas
@dprateek11
Jan 26 2018 12:14
@mnazim ok thank you
Ghost
@ghost~56fc9ded85d51f252abbbbad
Jan 26 2018 12:15
also room_status, enum?
:D
"Came for help got a code review"
Prateek Dabas
@dprateek11
Jan 26 2018 12:15
@cisco87 thats fine i am newbie just trying new things in life
@cisco87 thank you i didn't knew about enums
Ghost
@ghost~56fc9ded85d51f252abbbbad
Jan 26 2018 12:17
you welcome
Mir Nazim
@mnazim
Jan 26 2018 12:19
One must have decent knowledge of RDMS concepts and SQL for using Django ORM, otherwise one is going to have a very bad time.
Django ORM is not something that magically excuses one from understanding relational databases and SQL
If those are your weak areas, spend time on it first.
Prateek Dabas
@dprateek11
Jan 26 2018 12:20
@mnazim ok will do that
thanks
moneer-alasmar
@moneer-alasmar
Jan 26 2018 18:34
Can anyone help me in figuring out which of my models are a ManyToMany and which just require a FK?
It's just a basic site where a user can schedule trips, join other people's already planned trips.
Any help is greatly appreciated!
emihir0
@emihir0
Jan 26 2018 19:17
don't post files, either type the code directly here or use something like https://pastebin.com/ ...
moneer-alasmar
@moneer-alasmar
Jan 26 2018 19:59
Thanks for the help /s