Skip to content
Advertisement

Tag: django

Implementing CSS in Django

I’m trying to implement a simple CSS file to my python web app. When I try loding the app, I get a error message in the command prompt that says: And of course no CSS is implemented to the HTML page. The structure of my Project is: In my settings.py, I got: And in the html I got the link

How can auto create uuid column with django

I’m using django to create database tables for mysql,and I want it can create a column which type is uuid,I hope it can generate the uuid by itself,that means each time insert a record,I needn’t specify a uuid for the model object.How can I make it,thanks! Answer If you’re using Django >= 1.8, you can use a UUIDField: Passing default

Field name `username` is not valid for model

I am attempting to use rest-auth supplied serialisers to GET (*with headers) user details from the defined endpoint /rest-auth/user/ (*with headers (Content-Type: application/json Authorization: Token 1a5472b2af03fc0e9de31fc0fc6dd81583087523 )) I am getting the following traceback: https://dpaste.de/oYay#L I have defined custom user model (using email rather than username)as such: Settings as follows: Not sure how to go about correcting this error.. so that

Django Rest Framework Database Error Exception Handling

Is there any way to have Django Rest Framework automatically respond with HTTP_400_STATUS’s when there are database exceptions? (IntegrityError and so on) Example: I have a model with a unique username field and I’m trying to use a generic rest_framework.ListCreateAPIView. HTTP_400_STATUS’s are normally thrown automatically if serializer validation fails but this is actually valid input, just not valid in the

Django change database field from integer to CharField

I have a Django app with a populated (Postgres) database that has an integer field that I need to change to a CharField. I need to start storing data with leading zeros in this field. If I run migrate (Django 1.8.4), I get the following error: I tried searching Google, but didn’t really find much help. I don’t really know

Django Model Field Uniqueness Validation

I have a django user model that has fields ID, PW and DeviceID. The database I’m using is MySQL. In this model a user can have many different devices, so there can be many identical ID & PW (same user), with different DeviceIDs in the table. But if all the 3 fields are the same, then it is considered the

Advertisement