These are chat archives for django/django

25th
Feb 2016
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 06:48
@megapctr thanks! exactly!
Filip Figiel
@megapctr
Feb 25 2016 07:46
@AaronKazah please be more specific, we can't know what "features list" is
*featuted
sumit sinha
@sumitsinha91
Feb 25 2016 08:59
still i am facing this error
mobile_number = models.CharField(max_length=80, blank=True, null=True)
this line is not accepting on my model
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 09:00
@sumitsinha91 makemigrations?)
Filip Figiel
@megapctr
Feb 25 2016 09:06
@sumitsinha91 please always provide the exception and message
sumit sinha
@sumitsinha91
Feb 25 2016 09:17
after makemigration same problem
even i have done migrate also
Aaron Kazah
@AaronKazah
Feb 25 2016 09:57
@megapctr Sorry about that
I meant to say
A featured list as in
For example sorting blog posts
By popularity
For a certain time period
I have lists of start ups I want to display similar to product hunt and I was wondering how I'd
Achieve something similar to them
Do i
Olansile Ajibola
@tantita
Feb 25 2016 10:45
Hi, pls I need help as regards SqlAlchemy (I'm using it with flask), can I ask here?
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 10:46
@tantita It’s django room)))
Olansile Ajibola
@tantita
Feb 25 2016 10:47
I couldn't find any room dedicated to flask/sqlalchemy
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 10:53
@tantita ok! give your question
Olansile Ajibola
@tantita
Feb 25 2016 10:57
tnks
Olansile Ajibola
@tantita
Feb 25 2016 11:03

I have a table 'restaurants', table 'foods', and a table restaurant_foods(id, restaurant_id, food_id, food_price) wc holds d many-many relationship between 'restaurants' and 'foods'.

Then in my models I have:

restaurant_foods = db.Table('restaurant_foods',
    db.Column('restaurant_id', db.Integer, db.ForeignKey('restaurants.id')),
    db.Column('food_id', db.Integer, db.ForeignKey('foods.id')),
    db.Column('food_price', db.Float)
)

and in the Restaurant model I have a field:

foods = db.relationship(Food, secondary=restaurant_foods,  backref=db.backref('restaurants', lazy='dynamic'))

but when I run the query it does a join to the foods table only

I want to be able to get the food_price too in the result
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 11:14
@tantita send your query, please
Olansile Ajibola
@tantita
Feb 25 2016 11:16
Restaurant.query.first().foods
it's working, but my problem is that d M2M table has an extra field which I want to get
Dmitry Grebenshchikov
@grebenshchikov
Feb 25 2016 11:19
@tantita that rerurns the query?
tulpn
@tulpn
Feb 25 2016 14:12
Hello, I have a problem and cannot really find something via Google and was wondering if someone could give me their thoughts on Race Conditions in select statements with Django. I have tried to put my .filter() into a transaction and use select_for_update. Though I never do any update with the data. Unfortunately, when two client request the url, the second never gets the correct data
Arcady Usov
@itcrab
Feb 25 2016 17:40
Hi Guys and Girls, maybe some one know about any applications for auto-count field for model (category <- product): when we add the product in current category auto-count field will be ++ and all categories above current category (categories tree with django-mptt) too ++ in auto-count field, when we delete product - do -- in all needed categories.
Thumbi Migwe
@thumbimigwe
Feb 25 2016 19:16
hi guys, i need your help.....
how can i do this?..... making a website that uses facebook/twitter/gmail to login and stores this info information on a mongodb using python django.
Thumbi Migwe
@thumbimigwe
Feb 25 2016 19:22
or..... where can i find a tutorial for this.... I have an avid hunger for learning, trying, creating and developing things.
agent3bood
@agent3bood
Feb 25 2016 19:45
@thumbimigwe hi you canuse allauth module for social logins it is streat forward.
Filip Figiel
@megapctr
Feb 25 2016 20:08
@itcrab just define a property which calls objects.count()
@itcrab if you really need to store the count in the database, you can write receivers for model save and delete signals
@itcrab but then you'll have to write a management command which refreshes the count columns in case some data is lost or a bug is introduced. You'd want to run it hourly or weekly
@itcrab also you'd want to use django.db.models.F objects to perform increment/decrement on the database level
Filip Figiel
@megapctr
Feb 25 2016 20:13
As you see storing such data is a big hurdle, so I'd strongly recommend using count()