django-models

badly formed hexadecimal UUID error string for a UUID primary key

允我心安 提交于 2019-12-31 05:37:06
问题 I'm trying to get my table to load, but am getting this error, most likely because my primary key is a uuid. Here is my url paths. path('results/', views.results, name='results'), path('results/<uuid:pk>/', views.genre_book, name='books_genre_table'), Here is my views.py If there is one observation, we load the price table. If not, then we load a table with service descriptions. The user can then pick the service they are most interested and click through to the price table for that service.

Django Union Query

瘦欲@ 提交于 2019-12-31 04:21:10
问题 I need to develop a UNION query in Django with 3 models namely WebQuery,WebReply and BusinessOwners and the output should be of the form below. { "(#conversation_id#)_(#b_id#)": { "from": "(#user_id)", "email": "(#user_email)", "date_time": "#get from db", "query": "are you open ?", "from_r_id": "(#representative_id)", "from_r_name": "(#rep_name)", "business_registered": "FALSE" "to_business_name": "CCD saket", "chat": [{ "direction": 1, "text": "yes sir", "date_time": "424 577" }, {

Django: put offline a post after an event

試著忘記壹切 提交于 2019-12-31 04:13:21
问题 I'm trying to put offline the posts after an event, a definite date. I've developed a simple model for test my aim and inside the model I've put a function( named is_expired ) that, ideally, must define if a post is or not is online. Below there is the model : from django.db import models from django.utils import timezone import datetime class BlogPost(models.Model): CHOICHES = ( ("Unselected", "Unselected"), ("One Month", "One Month"), ("One Year", "One Year"), ) title = models.CharField(

Django - manage.py sql APPNAME not generating model SQL

走远了吗. 提交于 2019-12-31 04:06:47
问题 I have a relatively large flat application that I'm working on. To maintain separation of concerns, I've split the model and view files into auth_models , dashboard_models , taxonomy_models and more. These have been placed in the folder structure as APPNAME/ app/ models/ __init__.py auth_models.py dashboard_models.py taxonomy_models.py ... views/ __init__.py dashboard_views.py taxonomy_views.py ... My app/models/__init__.py has the following: from auth_models import * from dashboard_models

Using Django to summarize Report

≡放荡痞女 提交于 2019-12-31 03:12:21
问题 I'm trying to produce a table that will show the total maturity amounts for each financial institution that a plan has. A plan is the term I use for person. So each person can have multiple investments. I'm having trouble creating a table that will do this correctly. Currently I have a report that displays each investment sorted by Maturity Date, i.e. 2011,2012, etc. At the bottom I would like to place this summary table, but my query displays duplicates of each financial institution, due to

Circular dependency in Django ForeignKey?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 02:56:10
问题 I have two models in Django: A: b = ForeignKey("B") B: a = ForeignKey(A) I want these ForeignKeys to be non-NULL. However, I cannot create the objects because they don't have a PrimaryKey until I save(). But I cannot save without having the other objects PrimaryKey. How can I create an A and B object that refer to each other? I don't want to permit NULL if possible. 回答1: If this is really a bootstrapping problem and not something that will reoccur during normal usage, you could just create a

Django: Validation error in Admin

本秂侑毒 提交于 2019-12-31 02:33:08
问题 NEWBIE ALERT! background: For the first time, I am writing a model that needs to be validated. I cannot have two Items that have overlapping "date ranges". I have everything working, except when I raise forms.ValidationError, I get the yellow screen of death (debug=true) or a 500 page (debug=false). My question: How can I have an error message show up in the Admin (like when you leave a required filed blank)? Sorry for my inexperience, please let me know if I can clarify the question better.

Filter select field in ModelForm by currently logged in user

╄→尐↘猪︶ㄣ 提交于 2019-12-30 13:36:21
问题 I'm trying to display a form (ModelForm) with a select field filtered by currently logged in user. The select field in this case contains a list of categories. I want to display only the categories which "belong" to the currently logged in user. The category field is a foreign key to the IngredienceCategory model. Here is what I've come up with so far but it's giving me an error (unexpected keyword queryset). Any ideas what I'm doing wrong? # models.py class IngredienceCategory(models.Model):

how to query a many to many relationship?

房东的猫 提交于 2019-12-30 12:38:12
问题 I'm trying to build an e-learning platform I have users (Utilisateur) who can take several courses ,each course have several modules and a module can be in several courses A user can be a student or teacher or admin, a student is "managed" by a teacher or several and a teacher can also be managed by a teacher (if he is a researcher) ,teachers are managed by admins I'm not familiar with many_to_many concept, please correct me This is my django models : class Utilisateur(models.Model): user =

How to test celery with django on a windows machine

≯℡__Kan透↙ 提交于 2019-12-30 12:22:56
问题 I'm looking for a resource, documentation or advise on how to test django celery on my windows machine before deploying on a Linux based server. Any useful Answer would be appreciated and accepted. 回答1: Celery (since version 4 as pointed out by another answer) does not support Windows (source: http://docs.celeryproject.org/en/latest/faq.html#does-celery-support-windows). Even so, you have some options: 1) Use task_always_eager=True . This will run your tasks synchronously – with this, you can