Rinta
How to write code , redirect to home?
Rinta
My project is ecommerce
Mo
hi everyone, if we have django rest api and we want to get access to the front data sent to api is it correct to write this code? suppose we have defined completely fields in model and serializers? thanks def get(self, request, *args, **kwargs):
data = request.data
Starttime = data['Starttime']
Mirco
Mo
use Django Rest Framework and serializers
i meant in Django Rest Framework. but this code does not work and give error. my question is about the method? this method and code are correct or there is another way? thanks
Mirco
Tips
Can we develop Banking application in Django as we build in Java Spring?
Mirco
John
Hey guys does anyone know how to display the no of views on a product to be displayed on the admin in a django e commerce website in django rest framework
Henil
Есбол
I plan to make 2 sites using django. Each site has its own theme. For example: Site A is an e-commerce site, and site B is a forum.
And I would like the users of the website to be able to share one account, this means that one (site A) account can log in to another (site 😎 website.
how can I do this ?
Evgeniy
Hello everyone. I want to improve my English and I can teach you Django + DRF. Please let me know in private message if my proposal interesting for you.
ivan ulchich
Django Admin Question:
1. I have one Char field on my model and one Foreign key field.
2. I change both in admin change form
3. Validating those two fields in custom form
4. If foreign key field does not pass the validation, i am raising ValidationError
5. Here is key-moment: after raising ValidationError execution flow goes between other through has_change_permission method, and there i need in some way to determine that there was an Exception raised (gracefully handled by Django itself) - HOW CAN I ACHIEVE THIS???
Why do I need this? - to distinguish has_change_permission result based on validation result
Sergey
Hi all! I developing some app and want to use in it queues of tasks. It need to be delayed, can store request, response. This task must send some requests to some server and store response after done it. What I can use for it and how to organise it properly?
Yaswanth
Difference between :
Httpresponse ("%s",some data) and
Httpresponse (some data)
Almaz
Sergey
you might be understand me incorrectly. I have next scheme:
1) mobile-app gives me some data to request from some url
2) I create task for it and give in response task_id
3) mobile-app can pending me for update task status
and yes I look for celery, but i need to understand how to do it well (in a proper way)
Mohammad
Can anyone help me how to write this url on ajax? When i click on submit button i get this error (404 not found)
url : '{% url 'home_page' %}'
My url pathern in urls.py
urlpatterns = [
path ('admin /', admin.site.urls),
path ('', views.home_page, name = 'home_page'),
]
DENNIS
Yaswanth
Why I am getting REMOTE_ADDR as my server IP address..?
Yaswanth
Mohammad
Anonymous
Anonymous
hello guys i have problem with showing images on my site
Anonymous
Anonymous
Daniil
Or get s3
Luis
If the file exists into you project/server then you need to take a look to your seetings and urls as the guys said.
srilekha
Anyone who took the master program in upgrade data science???
Anders (izzno / gooood) 🇳🇴
`'DIRS': [BASE_DIR / 'templates']
What does the "/" do ?
Anders (izzno / gooood) 🇳🇴
And whats it called ?
Mirco
And whats it called ?
It's pathlib
You can use it instead of os.path
It's like the join, you can compose easily a path by using the slash
Mirco
It's used by default from Django 3.x if I well remember and it's part of standard library
Anders (izzno / gooood) 🇳🇴
Wow thanks!
Anders (izzno / gooood) 🇳🇴
I'll have to read up on that ;)
Anders (izzno / gooood) 🇳🇴
I did not know if it were part of the language or "something" ;)
Mirco
Anders (izzno / gooood) 🇳🇴
I just got it... Slick... :)
They use the "div" method....
Anders (izzno / gooood) 🇳🇴
div
Anders (izzno / gooood) 🇳🇴
omg...
__div__
Mirco
Mirco
!job
Doragonsureiyā
Rule 🔟: Job-related offers are only allowed in the offtopic group.
To not be considered spam, Job offers must include:
• Skillset/techstack
• Contact information
• Brief job description
• Pay figure
• And can only be posted in @PythonOfftopic.
Anonymous
how can I create a custom model on admin by using existing one
Anonymous
I have a FK relationship and I have override the model.manager on active
Anonymous
Model A:
is_active: default
objects : filter only active objects
ModelB(A):
is_prime : true
objects : models.manager
prime_manager : filter only prime active user
Class C:
FK to Class A.
I wanted to seperate admin interface on A,B,C
Mo
if we want to have request.data in our DRF api for testing it should we use APIRequestFactory, RequestsClient and something like that? or there is another way ? since i got null value.
Mirco
.
Do we design with css in django?
.
I'm new too :)
Nikkey
Yes, do static files setting in settings.py
Michael
Hi guys, quick question about tests. I do not know why this information was so hard for me to find , but what I would like to do with my tests is to create a test version of my sqlite3 database with thousands of entries, that get populated by the test, and then test this database through manage.py runserver. Perhaps I am approaching tests in a wrong fashion, so correct me where I am thinking about this wrong, but to me it makes complete sense.
So I found this small bit in Django's documentation regarding creating a separate database for when tests are run. I then edited by settings.py file as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'TEST': {
'NAME': 'db.test.sqlite3',
},
}
}
Now, when tests are run, a db.test.sqlite3 file is created. But how do I run my server on it through manage.py runserver while also accessing all the newly created entries in Django Admin? And why was this information so hard for me to find (I spend more that an hour of research to find this solution)? What's the catch?
Nikkey
And use CSS file
Anonymous
retries=1
Anonymous
What’s bad about my question ?
أبو العباس
Hi, someone knows an easy way to migrate articles from WordPress to django ?
Jaime
From WordPress Download as Jason, xml, or something like this.
Ty
I have a question on many to one relations, I have a model that uses a foreign key to attach lots of records to a specific field in this model.
When I run a query on this model field I only get one record even though there are 50 records associated when I check django admin.
Here is the model:
class WalletData(models.Model):
address = models.CharField(max_length=200,primary_key=True,unique=True)
contract_address = models.ForeignKey(TokenData,on_delete=models.CASCADE)
last_bitquery_scan = models.CharField(max_length=200)
I am basically trying to get a list of the contract_address's that are within the WalletData model.
William
Ty
So my query is actually in a function ,
WalletData.objects.all().filter(address=address).get().contract_address.walletdata_set
Even when I break apart the response, I can get the WalletData set expected in the contract_data field in the WalletData model, but it only ever has one record. When I look in django-admin and I go to the wallet, and check the contract_data field there is a drop down with all of the TokenData names as expected , I just can't access this list of names from the code.
William
William
Remove all and get use everything inside filter
Ty
that returns:
<QuerySet [<WalletData: 0x99E4961b59c7469b20fBb0F19343d80921f480f9>]>
William
What is the address that you gave passed?
Ty
That one that it returned, essentially the query is the be used from the front end of the application, the wallet address is known, and on their initial call their token data is collected from a thirdparty api and added to the WalletData model, which will always show the address itself as defined in self.name.
Even when I go into the contract_data section of WalletData, I only ever get one result instead of the 50 in the database
Ty
I can get a screenshot one moment
Ty
https://prnt.sc/14n5l7z
Ty
I am basically trying to make it to where a single query will return all of the tokens associated with a wallet
Anonymous
How can I get the source code of type method in python?
William
Ty
Do you have another model?
class TokenData(models.Model):
name = models.CharField(max_length=200)
contract_address = models.CharField(max_length=200,primary_key=True, unique=True)
def save(self, *args, **kwargs):
#print('save() is called.')
super(TokenData, self).save(*args, **kwargs)
def str(self):
return self.name
class WalletData(models.Model):
address = models.CharField(max_length=200,primary_key=True,unique=True)
contract_address = models.ForeignKey(to=TokenData,on_delete=models.CASCADE,)
last_bitquery_scan = models.CharField(max_length=200)
def str(self):
return self.address
Anonymous
db_1 | 2021-06-08 04:27:34.879 UTC [37] LOG: database system is ready to accept connections
db_1 | done
db_1 | server started
db_1 | CREATE DATABASE
при запуске PostgreSQL’а в докере оно создает базу подскажите какой там дефолтный юзер и пароль
юзаю image postgresql13-alpine если это как то поможет
Ty
the entire file
William
the entire file
Write query and access the contact address by the query.contact_address