Sergei
or implement a new postgre database?
Sergei
Sergei
as I understand, my db does not delete unecessary columns and create new ones
inchidi
did not help
then you should find mixed migration files. you can see that migration files usually start with 0001...., 0002..., 0003..., ....
try find duplicate number
inchidi
Sergei
I have just deleted the app and created the same one but under another title
and it is working now
Sergei
I hope that I will not get such errors after developing my models
Sergei
inchidi
you're welcome
Anders (izzno / gooood) 🇳🇴
I have a custom function in a model to return a list of child categories in an item for the default admin site. How "can I ?" list_filter by it ?
Anders (izzno / gooood) 🇳🇴
def get_child_categories(self):
return [child for child in self.child_category.all()]
Anders (izzno / gooood) 🇳🇴
I use it in "list_display" but adding a function to a "list_filter" does not compute ;)
Anders (izzno / gooood) 🇳🇴
child_category = models.ManyToManyField('ChildCategory',
blank=True)
Anders (izzno / gooood) 🇳🇴
code in the model
Mirco
Have a look at the code here
It could help ya if I've understood your question
Anders (izzno / gooood) 🇳🇴
Mirco
Anders (izzno / gooood) 🇳🇴
😁
Anders (izzno / gooood) 🇳🇴
Yw 😀
You know... When you overcomplicate things its time to quit... All I had to to was to add the original child_category to the filter... You cant list manytomany but you can filter by them ....
Rajjix
when i usually do collect static you get an admin folder with it’s corresponding static files a bunch of stuff you can edit there check the css file or something
Anders (izzno / gooood) 🇳🇴
Anders (izzno / gooood) 🇳🇴
I was wondering if there was a build in attribute for this, there must be many people wanting to display one / or two fields...
Mirco
Rajjix
you’re aware that u can be display as many fields as you want there and they will autofit because of the style that is included, but i was saying if you want to change some style in the admin panel, that would be my way of doing it, i’m sure there are other ways as well
Anders (izzno / gooood) 🇳🇴
Yes, but look at the screenshot, thats not autofit, thats auto bruce lee... Its on each side.
Rajjix
Anders (izzno / gooood) 🇳🇴
yep :)
Anonymous
how to work with form errors in django? I'm trying to create a user, sometimes I get it, and sometimes it just will not. Even typing both passwords correctly and username not yet used.
Here are the codes: https://pastebin.com/KFCSEA59
Rajjix
i don’t usually do this style, just inherit your fields from the user model and use clean methods to validate, if error you just do a raise validation error i have a snippet if you wanna check it out full user sign in/up with validations
Maz
Would you rather deploy a Django 1.11 app to Ubuntu 16.04 or Ubuntu 18.04?
Why?
Anonymous
Rajjix
you can add a validators field as well
Rajjix
username = models.CharField(
max_length=64,
unique=True,
validators = [
RegexValidator(regex = USERNAME_REGEX,
message='Username must be alphanumeric or contain numbers',
code='invalid_username')])I use this in one of my models and it displays the error if requirements not met should not be much different for form
Anonymous
Rajjix
Sec
Rajjix
https://pastebin.com/3JPWZKrG
Rajjix
you don't need that {{ form.username }}, just give your input fields a name
Anonymous
Rajjix
I don’t understand
Adonis
Hi guys !!! I am having a csrf validation error when my Django app is in production (debug=false), I am using nginx as reverse proxy and gunicorn as app server with ssl
Adonis
This principally happen on my subdomains
Adonis
How could I manage csrf protection when the same app is serving multiple subdomains
Rajjix
i had a similar problem, the reason in my opinion was with the ssl certificate i got from comodo not covering all of my subdomains
Rajjix
so i cancelled on using subdomain and redirected them all to uris instead
Adonis
Certificates ?
Adonis
So you stopped using subdomains ?
Rajjix
yep, like i didn’t need them much anyway
Adonis
But I need them I am working on a saas solution
Rajjix
are you using a self issued certificate?
Adonis
I have a ssl extended certificate on the main domain
Adonis
And a wildcard certificate on the subdomains
Adonis
They are all issued by global sign
Rajjix
well i have’t got that deep into certificates yet but based on how they work, if you’re using different certificates even if on same domain but diff sub-domains, the encryption and decryption will not match from one sub to another which might be the reason for your token problem, maybe you’re not using duplicate certificates for all your subdomains and main domain, which is basically the same certificate for several subdomains, usually a bit more expensive
Rajjix
but if you are using that already, than idk, help yourself out with google 😁
Adonis
Is actually the Django's csrf middleware use the certificate informations to generate csrf token?
Adonis
I thought that it only limited itself on the domain name check (Host or Referer header)
Adonis
Or something like that?
Rajjix
django is not the reason here, my point of view is that the whole purpose for the ssl is for encryption using that key you bind to your ssl, so that no information is being leaked during data transfer,
the token is encrypted and sent to the client, which the client decrypts with the certificate key, adds information in a request decrypts the token again with certificate key and sends it in the header, and then again the operation goes backs and forth, concerning the token decryption and encryption, but if you have 2 certificates for 2 subdomains they cannot encrypt each others data, so django will not be able to decrypt the token sent within the header if a request because he’s using a diff certificate on the second subdomain, so it does not accept it.
Anonymous
How much django feasible with mongodb I have read more blog and have got negative thoughts using django with mongodb
Bhagwat
How can we send push notifications in django...can anyone help me out!
Bhagwat
How to Allow users to delete objects creates by them???
Bhagwat
Like ads posted by them
Andrii
it seems that you are deleting only column instead of object
Andrii
can you show code plz?
Bhagwat
This error comes during user registration form with extra fields...
Andrii
there are 1k+ reasons for it
how smby can help u using only picture?
Rajjix
He’s playing around with his models, this should be primary auto incremented
Anonymous
https://dpaste.de/VeP7
Sergei
Hello everyone!
Does Django have OneToMany relation in addition to FK?
Andrii
Isn’t this an answer?
Денис
Anders (izzno / gooood) 🇳🇴
Anonymous
Anders (izzno / gooood) 🇳🇴
Use a webshop or write a lot of logic in the template-
Anders (izzno / gooood) 🇳🇴
There is no shortcut, you could look in to django-oscar, maybe use part of that. Or find a toturial for a django webshop and use that