Koen de
Hi folks is any troubles for upgrading django (with drf) project from 3 to 4? And may be there’s some version control for Python libs, that can find new one version , that not conflict with each other’s?
It is not a lot of trouble, however I try to only use the LTS versions of Django. pip will handle a lot of conflicting version for you. And you should always read and follow Djangos upgrade guide; https://docs.djangoproject.com/en/4.0/howto/upgrade-version/
Mihir
how to let user allow same for multiple times after signup, i have created employment model where i have used onetoone filed for user identification but it is not allowing me to create \n number of times to submit same form without specifying null=true in onetoone field., so how it possible to allow user fillup same form \n number of times with thier identity., so i can rener update form with user identity.
Mihir
Same form*
J
Can anyone teach me django
Doragonsureiyā
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
A.
How to use font awsome in admin django panel
Koen de
How to use font awsome in admin django panel
Since Django uses its own template mechanism for the admin panels too, You can easily override the templates used by Django. See this article: https://realpython.com/customize-django-admin-python/ Or get some inspiration from this project: https://github.com/fabiocaccamo/django-admin-interface
Hamza
How can I return as this in serializers
Doragonsureiyā
How can I return as this in serializers
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
Hamza
How can I return foriegn key field In model as nested sreilazer
Koen de
How can I return foriegn key field In model as nested sreilazer
Here is an example; https://www.sankalpjonna.com/learn-django/representing-foreign-key-values-in-django-serializers
Raad
Hello I have lists of countries, states, cities. Each country has states and each states has cities. I added the states and it working fine. For example if I select United state, it shows me the list of the states. My problem with cities, When I select the state, it pulls all the cities which around 4000+ cities. I want to get the list of the state cities only not all the US cities Here is my code https://pastebin.com/DSqHg6je
Raad
I am missing the code where you actually select the state. The code in pastebin shows us the JSONs and how you import them. How do you select your cities? It should be something like; City.objects.filter(state=state)
They are not exist. This script for the new deployment. This is where I'm struggling. I need to pull cities that belong to California using the state_id so it will pull small amount of cities instead of the whole list
Raad
So the states are exist since the code working till the city part. Sorry if I'm confusing you but the code will add countries first and then add the states. Last part is to add the cities
Koen de
So the states are exist since the code working till the city part. Sorry if I'm confusing you but the code will add countries first and then add the states. Last part is to add the cities
Lines 121/122/123 make sure the cities are created for the states they belong in. Apart from some optimizations I do not yet see what is going wrong. Is there an error or do you just have a lot of cities in the database? And those cities are not related to any state? I assume you are constantly working on a clean database?
Raad
So what is the right way to add the cities? is there any other way to load them directly from the json file instead of adding them in the database? I'm building a saas product and they should be available to all clients.
Raad
Lines 121/122/123 make sure the cities are created for the states they belong in. Apart from some optimizations I do not yet see what is going wrong. Is there an error or do you just have a lot of cities in the database? And those cities are not related to any state? I assume you are constantly working on a clean database?
I get this error ValueError: Cannot assign "'7'": "City.state" must be a "State" instance. Every city related to a specific state. For example, Alabama cities will have the state_id of Alabama. I deploy a separate server with its own db for each client.
Manheevak
My ValidationError in django forms are not showing error here is the forms.py link https://dpaste.org/KuvLg#L5,10
Koen de
Yes
Okay replace; state=st.state_id With: state_id=st.state_id
Raad
Okay replace; state=st.state_id With: state_id=st.state_id
This is mean I have to add new filed state_id in the city model?
Raad
This can be a correct way to do it. You can also suggest one big JSON with the three levels at once.
I see. Then I can use the forms to load them from the internet or locally?
Koen de
This is mean I have to add new filed state_id in the city model?
Django expects an instance of State at that part of your code. The trick is to use <field>_id to set an in instead of an instance and let Django find the instance itself
Koen de
I see. Then I can use the forms to load them from the internet or locally?
You can automate it, there are some open APIs around like https://public.opendatasoft.com/explore/dataset/us-cities-demographics/api/
Raad
No
I see
Raad
Okay replace; state=st.state_id With: state_id=st.state_id
TypeError: City() got an unexpected keyword argument 'state_id' I got this error when I change the state_id to anything else, I get this error DETAIL: Key (test_id)=(7) is not present in table "property_state".
Koen de
TypeError: City() got an unexpected keyword argument 'state_id' I got this error when I change the state_id to anything else, I get this error DETAIL: Key (test_id)=(7) is not present in table "property_state".
So the ids of the states in the json and the pks in the database do not equal. Okay. Then you should get a handle to the State before assigning it to the city
Raad
I suppose this is sufficient; state=st To create the city in line 125
I did and now all the cities are added to the db
Koen de
My ValidationError in django forms are not showing error here is the forms.py link https://dpaste.org/KuvLg#L5,10
Is clean_name actually executed? And what is the real value of “valname” before checking its len()? Both can be investigated with “pdb”
Manheevak
yeah it was not executed
Manheevak
i fixed it now
Raad
I suppose this is sufficient; state=st To create the city in line 125
But the same issue. it loads all the cities regardless of the selected state
Koen de
But the same issue. it loads all the cities regardless of the selected state
I do not understand your question. Yes all cities are imported because there is no filter. You just import them
Koen de
When you view the cities in the database or Django admin, are they related to a State?
Raad
I do not understand your question. Yes all cities are imported because there is no filter. You just import them
Thank you very much. I appreciate your help. I have a searchable dropdown and when I click on it, it makes the page slow. It also make a very long scrollbar
Raad
When you view the cities in the database or Django admin, are they related to a State?
they are not related right now. If I select Cali, it shows all the US citites
Koen de
Both have nothing to do with the import. Check if there is any filtering in the dropdowns. At least State should be provided to filter the cities.
Raad
Both have nothing to do with the import. Check if there is any filtering in the dropdowns. At least State should be provided to filter the cities.
They have ids that different then the one in JSON file. I can see the cities in Cali for example has the id "80" .
Hamza
Here is an example; https://www.sankalpjonna.com/learn-django/representing-foreign-key-values-in-django-serializers
When I try it I get this error when I used this object in fields in serializers
Hamza
Original exception text was: 'config' object has no attribute 'playstore'.
Arash
how to save filled form to database with class based views?
A.
I really need to send image for my question
Maxim
I really need to send image for my question
no, read the rules if you can't do without an image, you're probably in the wrong group
mahdi
Hello friends . Can you please explain the following concepts to me. 1-Annotate ? 2-Q? 3-F? 4-balk_create?
Koen de
Original exception text was: 'config' object has no attribute 'playstore'.
“was”? Have you solved your issue? If not; Can you post the complete errormessage, not just that line? Are you willing to share your code; Models, Serializers and View(set)s?
Koen de
Hello friends . Can you please explain the following concepts to me. 1-Annotate ? 2-Q? 3-F? 4-balk_create?
They are all in the documentation https://docs.djangoproject.com/en/4.1/ref/models/querysets/ https://docs.djangoproject.com/en/4.1/ref/models/expressions/ https://docs.djangoproject.com/en/4.1/topics/db/queries/
wayne
An error has occurred. I was making a form for adding news and got to writing a condition, but something went wrong. An error page appears when submitting the form https://hastebin.com/eputotiyev.py
NightE
How can I prevent a user from accessing other users' profiles ?
Doragonsureiyā
How can I prevent a user from accessing other users' profiles ?
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
NightE
I have searched burt I still need help
Юхим
Please anyone have an idea how to integrate a Dynamic Newsletter in a Django project🙏
..
I hv one excel upload feature in my django project. The file goes through few level of validations for each row and gets saved to database. I want to show real time processing progress status. How do I do it? Please help if you know any package or tutorial
Of course
docker run -d -p 4000:3000 -v $(pwd):/app docker: invalid reference format. error
Of course
on windows
Doragonsureiyā
docker run -d -p 4000:3000 -v $(pwd):/app docker: invalid reference format. error
This is not a Python specific question, please delete your offtopic message, move to @PythonOfftopic and ask there.
Koen de
How can I prevent a user from accessing other users' profiles ?
Well, this question has been asked a lot on StackOverflow, see https://stackoverflow.com/a/66869326
Koen de
I hv one excel upload feature in my django project. The file goes through few level of validations for each row and gets saved to database. I want to show real time processing progress status. How do I do it? Please help if you know any package or tutorial
It is not just that simple. A few things going on as you already mentioned. Here is an example with explanations https://buildwithdjango.com/blog/post/celery-progress-bars/
Eslam
guys how i can create script.py for open project by one click
Doragonsureiyā
guys how i can create script.py for open project by one click
What is this word salad supposed to mean?
Hamza
"detail": "Authentication credentials were not provided."
Doragonsureiyā
I get this error in post man That's my view
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
Hamza
How can I solve it
Ajay
https://ctxt.io/2/AAAQCA64FQ #help_
Ajay
How can i Solev
https://ctxt.io/2/AADgH3oAFA #Done
ayuLS
hi, i am using django with heroku, when i make change in local repository and then make deploy, my database (user) goes missing or returns to the way it was. is there a way to pull database from heroku to local repository ?