King Phyte 🐍
εz૨α
hello djangosists☺️
ken
hi. has anyone made a collection of foss django apps...
Gabs
can you install two versions of django? would be for different projects
Gabs
Thank you!!
Anonymous
Class 'Fullname' has no 'objects' memberpylint(no-member) any help?
Anonymous
from django.db import models # Create your models here. class Fullname(models.Model): lname = models.CharField(max_length=200) fname = models.CharField(max_length=200) mname = models.CharField(max_length=200)
Anonymous
from django.shortcuts import render from django.http import HttpResponse from sample.models import Fullname # Create your views here. def index(request): fullname_list = Fullname.objects.all('lname')[:5] output = ', '.join([q.fname for q in fullname_list]) return HttpResponse(output)
~~~
How to store time schedule and already booked data in django model
M
i have been struggling how i can use API end points in my webpages .. i am ok with Django however could not get much of use for DRF, e.g. dj_rest_auth is for various login/logout etc but how can i integrate it in my user management of webpage ... any blog on this
prasobh S
Would you please help me to write the views. py part. For monitoring the tank. once we filled the tank .then some water used for washing. Then the waterquantity subtract from the tank then update to tank.
Sumit
Hi, I am serving my django project on https . K have configured hsts too with it. But now I am not able to access static files. It is giving me error as you don't have permission to acess this files
Sumit
Even it is giving error for signup pages
Sumit
I am serving it with apache2
mukul
Even it is giving error for signup pages
Give read and write permission to database
Sumit
I am using postgresql
Sumit
How can give permission there?
Sumit
There is 403 error for all the static files
Sumit
And for signup pages it is giving internal server error
Anonymous
New to Django family but know CRUD operations using Django What type of project should I start using CRUD operations and then Api later. Suggest me Project name 😊
Tous
Book Library
Anonymous
🙏
Baku
How to deploy react and django server on same VPS and domain?
kritikos
How to deploy react and django server on same VPS and domain?
You can build your react app to get 1 JS file . Then add it in Django template file as static file..
kritikos
You can build your react app to get 1 JS file . Then add it in Django template file as static file..
You can also run it with docker. By using this tutorial https://medium.com/swlh/how-to-deploy-django-rest-framework-and-react-redux-application-with-docker-fa902a611abf
Baku
white screen after build react and deploy react app
Baku
how to fix that?
Baku
I tried all what I found in google
kritikos
white screen after build react and deploy react app
After build try to serve build folder with a static server.. and look in your index.html if there is html div you used to mount your react app in index.js
srilekha
Best course for django?????
âshîsh
Best course for django?????
Go to official documents
Alex
Best course for django?????
They are all the same. Plus or minus. Pick any.
srilekha
Ok
srilekha
Shall I pick newboston???
âshîsh
Shall I pick newboston???
https://docs.djangoproject.com/en/3.1/
Alex
Shall I pick newboston???
You can undergo any course and read any book you like. To master django (as any other software or platform) you will have to learn software architecture and databases anyway. And they are both separate themes.
Luis
Morning. What's the use of a property in a model for?
Alex
Morning. What's the use of a property in a model for?
Depends on your situation. Protip - using it for wrap db queris is a very bad idea.
Luis
Is it like an attribute we 'can't' define on the attibutes part because it would create a field in the database?
Luis
like, if you want a complex representation like what you do with __str__
âshîsh
can you give me an example of a property in a model?
Models.py file- Charfield, Textfield, Intfield These are properties
âshîsh
class xyz(models.ModelField): fullname=models.charfield(max_length=100)
âshîsh
That looks like a field
Yea... Character field
Alex
can you give me an example of a property in a model?
It's a bad design decision, imho, but it's an example for a good usage of properties in models. Lets say you have an eshop and you check whether an order was paid or not. You have the Payment model which has a boolean flag if there was verification by a payment system that money are received. But sometimes for some reasons such verification may lag for long time. But a client calls you back and says that he already paid his order and it's really displayed in the payment system's dashboard. So we can add manual_verified flag for the Payment. So instead of checking them both in our code we can add a property maybe_payed class Payment(models.Model): @property def maybe_payed(self): if self.verified or self.manual_verified: return True
Alex
like, if you want a complex representation like what you do with __str__
Model should not handle representation logic. It's about holding data.
Alex
Models.py file- Charfield, Textfield, Intfield These are properties
These are descriptors. Yes, they are properties, but they handle much complex logic.
mohammad
Hello guys, I transferred a template to Django and it is OK It only has one login that has a separate login and separate links and scripts The same css and js are separated Now should I introduce these links where I introduced my index link or Create a directory called Reference Login, for example, and drop it there. Or there is another way Which is more efficient and standard? Your mouth is hot.
Ekta
Hello alex
mohammad
#project hello every one i have a project that want to add new option to it . the backend is django is exist enyone for help me The method of cooperation is hourly. please come to pv.
Alex
What do you mean by duplicate a state?
I mean it would duplicate state if we define it as a field. Once again a bad example, but the one I can provide right now - phone numbers. Or names. Say we store a phone in our db like a string of numbers with any other characters truncated. Like 79998887776655. But for a user we want to represent it like +7(999)888-777-66-55. So instead of defining one more model field with that, we could make a property to make a userfriendly representation from the first one. Again, it is actually a bad design because neither model, nor db should be responsible for representing your data, but it's an example of handling duplication.
Alex
Why not define this on the str method?
Because that would be a method without any arguments (except for self ofcourse)
Alex
Because that would be a method without any arguments (except for self ofcourse)
And actually it should be a template filter of even a tag if you actually need much complex logic.
Alex
Why not define this on the str method?
Oh, you mean __str__? Because it's responsible for representing a model (in contex of django), but we want to represent only the field.
Luis
Also, a representation limits further possible use of data
Alex
Also, a representation limits further possible use of data
What? No. It's simply another layer of logic.
Богдан
How to make ModelForm if one field is ForeignKey? The api passes the ‘code’ field to the Insurance model, not the Insurance object itself So I have to find Insurance by code and write it in Contract in the insurance_company FK-field https://dpaste.org/yUVT
Luis
I mean the __str__
Alex
I mean the __str__
And what's wrong with it?
Luis
And what's wrong with it?
You just use it when you print the value, usually you don't use it for further calculations
Luis
I'm trying to determine when to use a property, I think I got it
Luis
I was using the __str__ not only to give a friendly representation but also to display a long representation with all the fields
Luis
Including, a complex representation of a flag
Luis
Basically, I was doing a lot of logic on __str__
Alex
Basically, I was doing a lot of logic on __str__
In django templates are representation layer.