godmode
okey now i'm int e computer this is much more better!!! What a change!
cj
you can:
1) Modify the HTML according to your needs
2) Make all the logic in the views and send the desired output via the context
godmode
The views is a class based view and it returning me the posts
Mirco
godmode
i don't i'll change the view cuz what i'm looking for is a simply logic... maybe o could change the template if i see there i no other way
godmode
i don't think*
cj
godmode
okey! Then i'll take that in mind...
godmode
i'll do it!
Mirco
godmode
thank you
Mirco
thank you
I suggest you 2 Scoops of Django as good read
Anonymous
Anyone work on django cms
Anonymous
Anonymous
Anonymous
Django CMS is good too
Yess Django CMS has very good documenting and on top of that it's easy to use. Same with wagtail with just with latest features and support
Ghorz
Anonymous
After hours of debugging It worked) http://whatmode.pythonanywhere.com/
Muflone
Not a great result, so far 😄
Anonymous
I know)
Anonymous
But it's just the begining)
Anonymous
There was also a problem with MIDDLEWARE🙃
Muflone
Nevermind, I'm just kidding
Anonymous
Now it's called as MIDDLEWARE_CLASSES
Anonymous
huh
Anonymous
John
Im using Django 2.2, Im having a problem of using the "login_required" decorator. I want my user who is trying to enter a view/url to go back again to my login page if he/she is not authenticated. .
Mirco
John
Im getting the 404 page error, what I want is to redirect my user to my login page if he/she is not login/authenticated. ..
Mirco
John
do I have to create a middleware or login_required decorator will do?. .
Mirco
Mirco
share your code please
Ritika Tiwari
Hey anyone can send me add to cart logic in django and display item in a cart
Ritika Tiwari
Or can tell me how to do it
pino@mastrobirraio ~$
https://github.com/bmentges/django-cart
pino@mastrobirraio ~$
just only search on google 😜
John
login_required is enough
How can I redirect it to my login page?. . I tried to use this "/accounts/login/" but Im getting the 404 error. .
Ritika Tiwari
Mirco
Ярик
hey guys, i need your help
i have two models like so:
class Stock(models.Model):
stock_name = models.CharField()
stock_quantity = models.IntegerField()
class Orders(models.Model):
order_name = models.ForeignKey(Stock)
order_quantity = models.IntegerField()
First off i fill in the Stock and then i have to add orders which are based on stock model
when i add order, i choose stock_name from Orders model and enter order_quantity
the thing i want to do is when i save Order with order_quantity it would automatically subtract it from a stock_quantity on save
how can i make it?
Mirco
Mirco
post_save sent by Order model
Ярик
def save(self, *args, **kwargs):
self.order_name.stock_quantity -= self.order_quantity
super(Order, self).save(*args, **kwargs)
i made this one , but it's not working
Mirco
Ярик
that's what i'm doing rigth now
thanks
Mirco
Doragonsureiyā
Ярик
and one more question
how to raise an error message if stock_quantity is less than order_quantity?
Ярик
p.s. i've already made a post_save signal
Mirco
Ярик
ty
Oleg
I'd rather use a form to validate the model before it's saved.
Mirco
Ярик
can you explain more pls?
Ярик
if you can ofc
Oleg
can you explain more pls?
Check out official docs: https://docs.djangoproject.com/en/2.2/topics/forms/#building-a-form
Basically you create a form class which validates the data before saving the model. You can add custom validation rules by overriding clean_<field>() and clean() methods
Ярик
Ярик
i don't have any templates and custom forms
Oleg
Afaik I can set custom forms for django admins.
Oleg
For example: https://stackoverflow.com/questions/24802244/custom-validation-in-django-admin
Oleg
I googled django admin custom validation
Ярик
ty, i'll try
Ярик
got it
i just created clear(self) function in my models file and raised an exception there
Anonymous
ModelForm have many fileds, Ones are fields that we see, Ones are error fileds that you dont see them
When i render form like {{form}} the UI is unacceptable
How can i modify it and access all fileds one by one?
like form.nameInput
Игорь
There is definitely a tag <form> ... </ form> ?
Mirco
Ярик
Found another file with the destination path 'admin/js/SelectFilter2.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
get this erorr every time after manage.py collectstatic
Ярик
i also get about 10 of these at one time
Ярик
do you know what's the reason?
Rainur
how to do url mysite.com/articles/?tagid=12 ?
Rainur
thank you in advance!
cj
Rainur
got it!) i wanna write this url in template