Luis
Hi guys! I'm using ModelForm and need to add extra field (password) to the form. How can I do it ?
R
Hi guys! I'm using ModelForm and need to add extra field (password) to the form. How can I do it ?
I think that by just declaring the field like pass = forms.CharField() and adding it to the fields meta
Luis
I think that by just declaring the field like pass = forms.CharField() and adding it to the fields meta
Oh! Thanks for your time! I'm trying this tip: https://chriskief.com/2012/12/17/subclass-a-django-model-form-and-add-extra-fields/
Luis
I think DJango 1.11 breaks when you use fields = ('_ _all_ _') and try to add extra fields
R
Just don’t use all, and define explicitly all the fields you want in your form
Luis
Just don’t use all, and define explicitly all the fields you want in your form
Yep, but get same error... django.core.exceptions.FieldError: Unknown field(s) (extra1, extra2) specified for Profile
Luis
https://stackoverflow.com/questions/30761411/add-extra-field-to-modelform
Thanks! It's working now. I was using PasswordInput for extra1 and extra2 field. Now I'm using Charfield and it works.
R
👍👍
Luis
👍👍
Thanks for your time!
Prosto
Hello evbdy! Need help with django-flatpages. I have footer.html template and there is lot of links like <a href="/about/" target="blank">{% trans "About company" %}</a> Its ok with transltation of 'About company', when im switching language. But how to switch link to other language?
Prosto
i was trying to solve it by django-modeltranslation. fork flatpages to my apps, make translation.py. and command update_translation_fields is showing that everything is ok - Updating data of model '<class 'apps.myapps.flatpages.models.FlatPage'>' . But there is no second language fields.
Prosto
Any solutions pls!
R
Otherways, you can look at how they do it in this package which seems to be using the same approach as you are trying https://github.com/PragmaticMates/django-flatpages-i18n
George
https://stackoverflow.com/questions/30761411/add-extra-field-to-modelform
i did this but with a query in which the default value was the last value assigned
George
hi, how would you make a subdir structure? I think i should replace or escape spaces. How should i deal with this? In my app i replaced spaces with underscore.
dhelbegor
Hi guys, can someone help me with a doubt please? I'm trying to use tox and pytest in my django project but the tox don't find my python path, i'm using virtualenvwrapper and unfortunately pyenv is not a option
dhelbegor
this is the error
dhelbegor
ERROR: py36: commands failed
inchidi
Yes
why you think you need to remove spaces? url work with spaces tho
George
why you think you need to remove spaces? url work with spaces tho
mmm i don't know, i think it's maybe easier without them
Anders (izzno / gooood) 🇳🇴
django-rest-api: I have a serializer of a model that has a field named accessories which is a foreign key to objects of the same model. To display the "ID" of the accessory I have to create another serializer basically doing the same thing (repeating code) because you can not refer to the class you are in. Is there a better way? https://pastebin.com/8dYe1iwf
dhelbegor
😁
Rajjix
This should be deleted ? with a nice ban for this guy advertising stupid stuff in an educational group
Jimmies San
@bharhshhabih76 not spam or will be banned.
George
Hi, where should i post a blog about django?
Rajjix
i like quora
George
hummm, but posting a coding blog about django in quora i don't think it would be appropiate
George
mmmmm, maybe but i don't feel that confident haha
Jimmies San
George
medium is not expected to have really profesional editing right?
Rajjix
or just google any django question and find on which site people mostly post such stuff, and get most views, these are the kind of sites u’ll find ur viewers on
Jimmies San
medium is not expected to have really profesional editing right?
it depends: i found a lot of good stuff on medium
George
i will try in medium, also i would like to have a kind index like: "These are all my posts"
Rajjix
Start your own blog with django 😃 takes you a couple of days to build with 10$ domain name ssl included
George
i don't want to spend money xD
Jimmies San
and you have statistics about visit/views
George
i'll do medium
Jimmies San
something like that
Jimmies San
it's really cool
George
yay
Jimmies San
:)
George
i am going to put the interesting "difficult" things that i coded
Jimmies San
Rajjix
Can’t wait 🤓
Jimmies San
i like a lot code snippets inside the post, or a git repos with all source stuff [just an idea :)]
George
i like a lot code snippets inside the post, or a git repos with all source stuff [just an idea :)]
mmmm yes, hem, i will put code snippets, it's fast for me. Also building repos for a single utility i don't think. I prefer people sorting out by themselves, not to copypasta. Also, changes in the software fuck up many things
Jimmies San
share?
yes, typo :P
George
sareh 👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾
George
Also, how do you comply in Django with 80 characters pep rule? It's kind of impossible
George
Oh, i just found out https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/ An exception to PEP 8 is our rules on line lengths. Don’t limit lines of code to 79 characters if it means the code looks significantly uglier or is harder to read.
George
I added flake8 extension in emacs so it's always red
Anders (izzno / gooood) 🇳🇴
This is so anoying: https://pastebin.com/e8iX4Xn3 I've tried with supers, lambdas so on and so forth, but for this case i CAN not not repeat code... frustrating.
Anders (izzno / gooood) 🇳🇴
I know I should just move on, its working...
Mirco
Have u tried to inherit AccessorySerializer inside ProductItem ? So you inherit all attributes from it and then specify it by adding accessory field If I don't go wrong
Anders (izzno / gooood) 🇳🇴
I could but that would not be very readable as it would be the wrong inheritance (or wrong way). And i would have to repeat the fields as they are slightly different.
Rajjix
make one field list at the top
Rajjix
Class meta = field list
Rajjix
second
Rajjix
Class meta =field list + access
Rajjix
Roughly
Anders (izzno / gooood) 🇳🇴
Can you add to tuples ?
Rajjix
Yes
Rajjix
only tuples
Anders (izzno / gooood) 🇳🇴
I did not know that.
Anders (izzno / gooood) 🇳🇴
:D
Rajjix
1, 2, 3 + (1, )
Anders (izzno / gooood) 🇳🇴
hah
Anders (izzno / gooood) 🇳🇴
Then inheritance is the way to go ;)
Rajjix
i guess
Anders (izzno / gooood) 🇳🇴
will just be fields += ('accessories')