cj
The html template comes from colorlib
it doesn't matter, you have the HTML files in your project, you "own" them
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
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
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
remember, templates are not meant to hold logic, templates should be as dumb as possible, make your logic in the views
godmode
okey! Then i'll take that in mind...
godmode
i'll do it!
godmode
thank you
Mirco
thank you
I suggest you 2 Scoops of Django as good read
Anonymous
Anyone work on django cms
Anonymous
Anonymous
Anyone work on django cms
Yes I tried it once
Mirco
Try wagtail
Django CMS is good too
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
You'll want window functions. See an example here: http://sqlfiddle.com/#!15/9fd7a/8 Django 2.0 supports Lag() and Lead() https://docs.djangoproject.com/en/2.0/ref/models/database-functions/#window-functions
https://dpaste.de/iCW4 this is the filter I wrote to do it, It works but i fear when the user base increases the system may slow down. Can you give me a sample orm. django docs dont quite give a sample
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
Nevermind, I'm just kidding
Nevermind, I know😊
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. .
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. ..
John
do I have to create a middleware or login_required decorator will do?. .
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. .
Ярик
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
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
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
have a look at django signals 😊 https://simpleisbetterthancomplex.com/tutorial/2016/07/28/how-to-create-django-signals.html
Ярик
that's what i'm doing rigth now thanks
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
Ярик
ty
Oleg
p.s. i've already made a post_save signal
I doubt you can show an error message from the signal handler.
Oleg
I'd rather use a form to validate the model before it's saved.
Ярик
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> ?
Anonymous
There is definitely a tag <form> ... </ form> ?
Yes, form is displayed. i want control over it's fields
Ярик
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!
Rainur
with the keyboard? 🤔
sorry i didn't understand your question
cj
sorry i didn't understand your question
you can write urls using the keyboard 🤷🏻‍♂️
Rainur
got it!) i wanna write this url in template