Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
No module named celery using python 3.6 and apache2
On my dev machine I installed and configured celery within a django app and it works without issues using python3.5 and the django dev webserver. When I deploy that app to my production server I get an error "no module named celery". On the production server runs python3.6 with apache2 and mod_wsgi. On both machines I use django-1.11 and celery-4.1.0 within a virtualenv. I suspect that it's either an issue with python3.6 or with mod_wsgi. I haven't found any real solution to my issue so I'm trying my luck here :) Cheers Michael -
Django Uncaught ReferenceError: flat_plate is not defined
First of I introducte the system.id into my JavaScrip which is an unique integer, and this gives no problems. However when I try to 'introduce' the system.system_type variable (which is a Django CharField) into my JavaScript I get the error: Django Uncaught ReferenceError: flat_plate is not defined. The (simplified) System model is defined as follows: class System(models.Model): system_name = models.CharField(default='default_name', max_length=200) system_type = models.CharField(default='flat_plate', max_length=50, choices = SYSTEM_TYPE_CHOICES) Here SYSTEM_TYPE_CHOICES is defined as: SYSTEM_TYPE_CHOICES = ( ('flat_plate', 'flat_plate'), ('helical_coil', 'helical_coil') ) The simplified Django template with JavaScript which I try to run is defined as follows: {% extends 'base.html' %} <script> {% block jquery %} {% autoescape off %} system_id = {{ system.id }} // runs without a problem system_type = {{ system.system_type }} // Gives an error {% endautoescape %} console.log("system_id is: "+system_id) console.log("system_type is: "+system_type) {% endblock %} </script> {% block content %} <p>Hello</p> {% endblock %} -
Django: Accessing ManytoMany field
I am currently facing the following challenge. As the visitor of my page you can select between different events. Let's say you clicked on one and now you are on the event page with the id 1. You can select between different tickets. Let's assume you selected Ticket 1 ( USD 100 ) with 19% VAT and Ticket 2 (USD 200) (includes Food) with 19 % + 7% VAT. Now you click on check out and the next page will list the following: 1x Ticket 1 - Total: USD 100 1x Ticket 2 - Total: USD 200 Total: USD 300 VAT 1 (19 %): USD 57 (19 + 38) VAT 2 ( 7%): USD 14 Subtotal: USD 229 I am now struggling with this ManytoMany field. How would you access the individual tickets get the VAT from the respective ManytoMany field and then display them at the end of my template? I considered tuple, dictionary etc. but I am really struggling to find the best approach here. Did you ever face a similar code challenge? class TicketTax(models.Model): event = models.ForeignKey( Event, on_delete=models.PROTECT, related_name='ticket_taxes' ) name = models.CharField(max_length=100) percentage = models.DecimalField( max_digits=5, decimal_places=4 ) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class … -
Strftime error Python
I'm calling a function to get the calculation for driver revenue but, I keep getting this error: "line 396, in driver_get_revenue monthly[month.strftime("%m")] = orders.count() * settings.DRIVER_DELIVERY_PRICE AttributeError: 'int' object has no attribute 'strftime'" The function is this: def driver_get_revenue(request): driver = JWTAuthentication().authenticate(request)[0].driver #Returns the difference between date and time. from datetime import timedelta revenue = {} monthly = {} yearly = {} today = timezone.now() month = today.month year = today.year #Created a range to calculate the current weekday. current_weekdays = [today + timedelta(days = i) for i in range(0 - today.weekday(), 7 - today.weekday())] for day in current_weekdays: orders = Order.objects.filter( driver = driver, status = Order.DELIVERED, created_at__year = day.year, created_at__month = day.month, created_at__day = day.day ) revenue[day.strftime("%A")] = orders.count() * settings.DRIVER_DELIVERY_PRICE for day in range(0, 30): orders = Order.objects.filter( driver = driver, status = Order.DELIVERED, created_at__month = month, created_at__day = day ) (Line 396) monthly[month.strftime("%m")] = orders.count() * settings.DRIVER_DELIVERY_PRICE for month in range(0, 12): orders = Order.objects.filter( driver = driver, status = Order.DELIVERED, created_at__year = year, created_at__month = month ) yearly[year.strftime("%y")] = orders.count() * settings.DRIVER_DELIVERY_PRICE return JsonResponse({"revenue": revenue, "month": monthly, "yearly": yearly}) I'm not exactly sure where I went wrong. I marked line 396 so that you see … -
Changing robot.txt in django
I've created a website using Django and added robots.txt using the code : path('robots.txt', lambda r: HttpResponse("User-agent: *\nDisallow: /", content_type="text/plain")), in my main urls.py , it works great but now i need to add some rules to it .. how to do it -
Django: Cannot assign "<Profile: Profile object (None)>": "Profile.user" must be a "User" instance
I'm trying to create a signup form using Django. I'm getting this error while submitting the form. Here's what I've done. models.py from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver class Profile(models.Model): profile_ID = models.IntegerField(primary_key=True) user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.ImageField(upload_to='img/', default='img/none/default-avatar.png') def updateUserProfile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() post_save.connect(updateUserProfile, dispatch_uid="app_models_updateUserProfile") views.py from django.shortcuts import render, redirect from django.views import View from django.contrib.auth import login, authenticate from django.contrib.auth.forms import UserCreationForm from .models import Profile # Create your views here. class SignUpView(View): templateName = 'auth/signup.html' def get(self, request, *arg, **kwargs): form = UserCreationForm() return render(request, self.templateName, {'form': form}) def post(self, request, *arg, **kwargs): form = UserCreationForm(request.POST, request.user) if form.is_valid(): user = form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('/') return render(request, self.templateName, {'form': form}) From the error traceback, I can see that the error is because of the fact that somehow two signup requests are being sent at a time. It shouldn't happen 'cause I've used this, post_save.connect(updateUserProfile, dispatch_uid="app_models_updateUserProfile") Here's the traceback, Error traceback #1 Error traceback #2 I guess I've done something silly. Please help! -
django rest framework - How to add post parameters to api document(drf_yasg)?
x_param = openapi.Parameter('x', in_=openapi.IN_FORM, description='srring', type=openapi.TYPE_STRING) y_param = openapi.Parameter('y', in_=openapi.IN_FORM, description='string', type=openapi.TYPE_STRING) @swagger_auto_schema(method='post', manual_parameters=[x_param,y_param]) @api_view(['POST']) def test(request): pass I used drf_yasg as a swagger. I did the coding above and tested it with swagger. And when I checked with Chrome, the request payload is "x = 124 & y = 124124". And, with the following message, a bad request error occurred. { "detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)" } Is it wrong to add post parameters to the swagger? -
django cerlery second task not executed
I created a celery shared_task which executes another shared_task: @shared_task(base=WorkerBase, name='analytics.worker-tenant', rate_limit='3/m') def worker_tenant(): tenants = Tenant.objects.values_list('id', 'contexttenant') print('first:worker_tenant') for tenant in tenants: worker_update_tenant.delay(tenant[0], tenant[1]) @shared_task(name='analytics.worker-update-tenant', autoretry_for=(HTTPError, ConnectionError), retry_backoff=True) def worker_update_tenant(id, context, timespan=timedelta(weeks=1)): print('worker_update_tenant') I get the output of the first print first:worker_tenant but not the second one worker_update_tenant. I have also tried to call the second task with apply_async(args=(...)) but that also didn't work! -
Python + Postgresql + Haystack for million rows search/updates
I am wondering if a postresql database is the best way to go for my project. I need to handle some 50 - 100 csv files with 100k - 2 million rows each. I need to delete and update this files daily, not all but many of them. I also need to run search queries to retrieve data from products in this DB. I will use Python requests to extract the info, maybe up to 800 queries PER DAY and post them in a site run on Django. Simply doing full text seach on this database resulted in crashes all the time. Is Haystack + Elastic Search or Whoosh the best way to go?? Any suggestion as to best architecture for optimal performance?? Many thanks!! -
NoReverseMatch with django-addanother Edit button
I am trying add edit button to ModelForm with django-addanother. When I am adding only AddAnother everything works perfectly, but when I am trying add Edit button I am getting NoReverseMatch, the main difference is that I am using there fk and I do not know how to connect that with my primary_key forms.py from django.urls import reverse_lazy from django_addanother.widgets import AddAnotherWidgetWrapper from django_addanother.widgets import AddAnotherEditSelectedWidgetWrapper class BookForm(PermissionRequiredMixin, ModelForm): class Meta: model = Book fields = ['title', 'author', 'summary', 'tag', 'genre', 'language', 'book_format', 'read_date'] #labels = widgets = { 'author': AddAnotherEditSelectedWidgetWrapper( forms.Select, reverse_lazy('author_form'), reverse_lazy('book_form', args=['__fk__']), ), } permission_required = 'libraryapp.can_edit' views.py from django_addanother.views import CreatePopupMixin, UpdatePopupMixin def book_create(request): if request.method == 'POST': form = BookForm(request.POST or None) if form.is_valid(): form.save() messages.success(request, ('Book has been created!')) return redirect('/') else: form = BookForm() return redirect('/') else: form = BookForm() return render(request, 'libraryapp/book_form.html', {'form': form}) class AuthorCreate(PermissionRequiredMixin, CreatePopupMixin, CreateView): model = Author fields = '__all__' permission_required = 'libraryapp.can_edit' class AuthorUpdate(PermissionRequiredMixin, UpdatePopupMixin, UpdateView): model = Author fields = '__all__' permission_required = 'libraryapp.can_edit' urls.py urlpatterns = [ path('author/create/', views.AuthorCreate.as_view(), name='author_form'), path('author/<int:pk>/update/', views.AuthorUpdate.as_view(), name='author_update'), path('book/create/', views.book_create, name='book_form'), So when I am using only AddAuthor it is working, but with Edit it alwyas get me this error: … -
from anshu.myapp.views import TaskViewSet ModuleNotFoundError: No module named 'anshu.myapp'
i am work on rest_framework in django. My working directory and project is show the below. When i run the server then error is occur "ModuleNotFoundError: No module named 'anshu.myapp'".So please help me any one for this solution thank you anshu anshu __init__.py settings.py urls.py wsgi.py myapp migrations __init__.py admin.py models.py Serializers.py tests.py urls.py views.py manage.py This is my settings file and any think i missed then suggest me to correct them settings.py INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp', 'rest_framework', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) urls.py from django.conf.urls import include, url from django.contrib import admin from rest_framework import routers from anshu.myapp.views import TaskViewSet router = routers.DefaultRouter() router.register(r'task',TaskViewSet) urlpatterns = [ url(r'^',include(router.urls)), url(r'^admin/', include(admin.site.urls)), ] In urls file from "anshu.myapp.views import TaskViewSet" is the problem to not run the server i am using:- python = 3 django = 2.0.3 rest_framework = 3.8.2 -
How to assign multiple model in a single html form in Django class based view?
Greeting, I am new in Django. I am working on Django 2.0. I need to show multiple model forms in a single HTML form and save it on one click. form.py file is here class BusinessProfileForm(forms.ModelForm): class Meta: model = StUserDetails fields = ('user_address1', 'user_address2', 'user_city', 'user_state', 'user_country','user_zip',) class AdditionalDetailsForm(forms.ModelForm): class Meta: model = StUserAdditionalDetails fields = ('phone_number', 'fax_number', 'corporation_number', 'tax_number', 'custom_name1','cutom_field_value1', 'custom_name2','cutom_field_value2') view.py class UserProfileView(LoginRequiredMixin, FormView): template_name = 'users/add_user_details.html' success_url = '/dashboard/' form_class = [ BusinessProfileForm, AdditionalDetailsForm, ] def form_valid(self, form): if form.is_valid(): profile = form.save(commit=False) profile.user = self.request.user profile.save() messages.add_message(self.request, messages.SUCCESS, _('Profile data has been successfully updated.')) return super(UserProfileView, self).form_valid(form) and HTML render is- <form action="POST"> <div>{{BusinessProfileForm}}(form1) <div> <div>{{AdditionalDetailsForm}}(form2) <div> <button type="submit">Save</button> </form> Please help me I am searching on google but never able to understand. please don't make it duplicate. i did not get same question for Django 2.0 -
Offline to Online Sync DB
I'm Developing a system where my client wants me to provide offline service and an online backup along with an iOS, Android, and Windows App. Things I Need: Support of Offline and online (master) DB that can sync when it's connected. Same for iOS and Android, but I'm little concern if those phones can handle this sort of job. What to use in case of Android and iOS in order to archive such goal. Suggest me with whatever you got. NB: I haven't decided anything but for the backend, I will use Python & Django. I'm still in the designing process. -
Seeding data through migration in 1.10
The problem is slightly tricky to define so please bear with me. I have a model called Blog. I have three migrations in it. 0001_initial: Create table for Blog 0002_seed_data: Seed some data into this table. To seed this data, I use: all_blogs = Blog.objects.all() for blog in all_blogs.iterator(): #some logic here blog.save() 0003_add_column: Add a new column 'title' to this table When I run 0003_add_column on a database where 0002_seed_data has already run in the past, it works. But when I run these migrations on an empty database, it fails at 0002_seed_data because it cannot find title in database. It gives an error similar to: django.db.utils.OperationalError: (1054, "Unknown column 'Blog.title' in 'field list'") This looks like a chicken an egg problem to me because 0002 cannot run until title column isn't present in table. There is provision to add title in table in 0003, but that cannot run until 0002 has run. A simple solution is to correct the order. This is what I have been doing in the past. But this means everytime I add a new column to this table, its order has to be corrected. A quick search of the error returns a few solutions and … -
how can i save .docx file data into modal table like excel sheet using django
How can I save MS word docx file data into modal table like excel sheet row wise, coloumn wise using django from subprocess import Popen, PIPE from docx import opendocx, getdocumenttext from cStringIO import StringIO def document_to_text(filename, file_path): cmd = ['antiword', file_path] p = Popen(cmd, stdout=PIPE) stdout, stderr = p.communicate() return stdout.decode('ascii', 'ignore') print document_to_text('your_file_name','your_file_path') -
Django: changing OneToOneField to ForeignKey ends up with 'User' object has no attribute 'profile'
The model I use is from the authtools package. AUTH_USER_MODEL = 'authtools.User' This is from my models.py class UserProfile(models.Model): # ... user = models.OneToOneField( settings.AUTH_USER_MODEL, related_name='profile') I've been working on this project for quite a while and have used multiple of the lines below**: user.profile user.profile.name user.profile.playlists # and many others Now for my use case, I realized I needed to have multiple Profiles for one login so I was planning to go from OneToOneField to ForeignKey class UserProfile(models.Model): # ... user = models.ForeignKey( settings.AUTH_USER_MODEL, related_name='profiles') ** With this, my previous codes need to be changed because I won't be able to call the old profile attributes freely because it will be returning a set, not a single instance. Instead, I want to do something like the following: user.profile = user.profiles.all().first() so that I don't have to change all the lines with user.profile. But I don't know where I can declare this and I badly need help because it's turning into a major blocker. Any ideas? -
uwsgi command return Permission denied on chdir
I have some Django application and I would like to run it with uwsgi I have command sudo uwsgi --chdir=/Users/markoz/Documents/Project --module=Project.wsgi:application --master --pidfile=/Users/markoz/Documents/project-master.pid --http=0.0.0.0:2222 --processes=5 --max-requests=5000 --vacuum --uid=10000 --gid=10000 When I run it I get error: chdir() to /Users/markoz/Documents/Project chdir(): Permission denied [core/uwsgi.c line 2629] chdir(): Permission denied [core/uwsgi.c line 1608] chdir(): Permission denied [core/uwsgi.c line 1644] and I don't understand why this is... -
Django multisite / server deployments
I'm setting up a custom built e-commerce project. One site will be for the UK and another inside another country, with the possibility of adding more at a later date. However, the sites have different integrations e.g. payment systems, warehousing etc. I want to keep to the databases separate as the sites will be running on separate servers. The issue i'm having is how to manage the sites. Ideally i'd like to have a master branch. So if say, i want to update the header of the website i can make the change, then roll it out to all websites. Rather than having to make the same change multiple times. However, some of the view logic might be different due to the integrations. So i need to keep the code separate. Should i create separate branches for each country/site? Then branch off of the master branch when i want to make a change to all sites? Also, each site will need to have a staging & live site. So in my head it looks like something like this: Master Branch -> (Quick template change for all sites) UK Staging Live Country Two Staging Live Country Three Staging Live Or do … -
django authentication and password reset
So, i am currently working on a web application project and i implemented authentication and password confirmation successfully. But my issue is that i did it using html templates and now the requirement came up that we have to develop our application using api's for the backened. Now, i am new to api and really confused how to use the authentication system i built (as we have to provide template to the in-built implemented class and they accept the values from their itself) Is it possible to actually see and manage the registered users from the code-behind while still using there in-built mechanism -
Django Celery periodic tasks
I've created simple django project for understanding how celery periodic tasks are working. Project named 'proj' have one app (name is 'sample') and one model ('Counter'). Counter model has only one integer field name value. I am trying to increase value of counter by 1 in every minute, but can't get it work. My files: proj/celery.py from __future__ import absolute_import, unicode_literals import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') app = Celery('proj') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() sample/models.py from django.db import models class Counter(models.Model): value = models.IntegerField(default=0) sample/views.py from django.shortcuts import render from .models import Counter def index(request): value = Counter.objects.get(pk=1).value return render(request, 'sample/index.html', {'value': value}) proj/tasks.py from celery.schedules import crontab from proj.celery import app from .models import Counter @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): sender.add_periodic_task( crontab('*', '*', '*', '*', '*'), my_task()) @app.task def my_task(): counter = Counter.objects.get(pk=1) counter.value += 1 counter.save() What am I missing? -
Create instance of model from method
I'm new in Django, got a problem. I have a method in Commodity Model: @transaction.atomic def payment(self): if self.owner.balance > self.price and self.active is False: self.act_time_till = now() + timedelta(days=1) self.owner.balance -= self.price # here i need to create a new Invoice object self.save() return True else: return False And I have a different model - Invoice: class Invoice(models.Model): commodity = models.ForeignKey(Commodity, on_delete=models.PROTECT) paid_till = models.DateTimeField(blank=False, null=False) value = models.DecimalField(max_digits=3, decimal_places=2, blank=False, null=False) How can I create an instance of Invoice every time I make payment? Thanks! -
Authentication to Node API from Django web app
I have Django web app, which is doing the authentication in default Django way. I have also Node API which is consumed by this Django web app. Node API's job is to handle with user specific data. The main problem is the authentication and creating the JWT token for user. Should I make custom authentication to Django which creates a token for the user and tries to login to my Node API on the same time? In my opinion, JWT could include the user_id and get cars by this value from API. I'm just lost how I can do the authentication to my Django web app and Node API. For example, here is my Node API's GET /cars route: app.get('/cars', (req, res) => { var token = req.header('x-auth'); var decoded = jwt.verify(token, 'JWT SECRET'); var user_id= decoded.user_id; if (!token) return res.status(401).send({ message: 'No token provided.' }); jwt.verify(token, 'JWT SECRET', function(err, decoded) { if (err) return res.status(500).send({ message: 'Failed to authenticate token.' }); }); function getCars(callback) { // DB CALL FOR CARS } getCars(function(err, content) { if (err) { console.log(err); res.send(err); } else { res.send(JSON.stringify(content)); } }); }); views.py for current view for getting cars from Node API. @login_required def cars(request): … -
Django-Ajax: submitting forms with AJAX that inludes a file field, giving me 500 error: Object of type 'FieldFile' is not JSON serializable
so, as the title states, im trying to upload a form using ajax, and the form , along with other fields, includes a FileField to upload an image. however, when I make the request, ajax cannot return a response to me because 'FILEFIELD is not JSON serializable'. so, here is the code: model: from django.db import models # Create your models here. class Employee(models.Model): name = models.CharField(max_length=255) job_title= models.TextField(blank=True, max_length=255) years_experience = models.IntegerField() PRODUCTION = 'PR' RESEARCH_DEVELOPMENT= 'R&D' PURCHASING = 'PU' MARKETING = 'MA' HUMAN_RESOURCES = 'HR' ACCOUTING = 'AC' DEPARTMENT_CHOICES = ( (PRODUCTION, 'Production'), (RESEARCH_DEVELOPMENT, 'Research and Development'), (PURCHASING, 'Purchasing'), (MARKETING, 'Marketing'), (HUMAN_RESOURCES, 'Human Resource Management'), (ACCOUTING, 'Accounting') ) department = models.CharField(max_length=2, choices=DEPARTMENT_CHOICES, default=PRODUCTION) image = models.FileField(upload_to='images/') def __str__(self): return self.name here is the associated modelForm: from django import forms from .models import Employee class EmployeeForm(forms.ModelForm): class Meta: model = Employee fields = ('name', 'job_title', 'years_experience', 'department', 'image',) labels = { 'years_experience': ('years of experience') } widgets = { 'name': forms.TextInput( attrs={'id': 'employee-name', 'required': True, 'placeholder': 'Employee name...'} ), 'job_title': forms.TextInput( attrs={'id': 'employee-job-title', 'required': True, 'placeholder': 'Employee title'} ), 'years_experience': forms.TextInput( attrs={'id': 'employee-years-experience', 'required': True, 'placeholder': 'Years of experience...'} ), 'department': forms.Select( attrs={'id': 'employee-department', 'required': True, 'placeholder': 'department...'} ), … -
How to add a sortable column from the admin log in Django
In the Django admin area I need to display when an object was last modified by another user. Therefore I want to leverage Django’s built-in admin log. I came up with this solution: class MyModel(models.Model): ... @property def admin_last_modified(self): from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType try: logentry = LogEntry.objects.filter( object_id=self.pk, content_type_id=ContentType.objects.get_for_model(self.__class__) ).order_by('action_time')[0] except: return '' return '{} by {}'.format(logentry.action_time, logentry.user) and the admin class: @admin.register(MyModel) class MyAdmin(admin.ModelAdmin): list_display = ( ..., 'admin_last_modified' ) The disadvantage, which is a show-stopper for me, is that the column is not sortable. For that, from what I’ve gathered, I'd need to re-formulate the property as some kind of annotation. But I’ve tried and haven’t come up with an idea how to do so: class MyAdmin(admin.ModelAdmin): def get_queryset(self): queryset = super().get_queryset(request) queryset = queryset.annotate( admin_last_modified=# ??? ) return queryset I’m now looking for what to substitute the question marks with. How can I write an annotation, that fetches one row of information from another basically unrelated table? -
Django ImageField url incorrect in admin view
I have a model that stores an image in a media subdirectory, "media/games/". The image uploads to the correct location but when I try to retrieve it in the admin page it's trying to retrieve it in the base media/ path, and doesn't seem to reach down into the games folder, so that if I look under: localhost:8000/media/games/image.png it will show the image, but if I am in admin and click on the image link for the preview it tries to find it at: localhost:8000/media/image.png Shouldn't the ImageField be "games/image.png" instead of just "image.png"? I don't think the image field is storing the path correctly. Here are my files: MODELS: from django.db import models from django.core.files.storage import FileSystemStorage fs = FileSystemStorage(location="media/games/") class Game(models.Model): title = models.CharField(max_length=127, unique=True) slug = models.SlugField(max_length=127, unique=True) summary = models.TextField(null=True, blank=True) description = models.TextField(null=True, blank=True) release_date = models.DateField('date released', null=True, blank=True) released = models.BooleanField(default=False) purchase_link = models.URLField(max_length=255, null=True, blank=True) card_image = models.ImageField(storage=fs, null=True, blank=True) created = models.DateTimeField(auto_now_add=True) updated = models.TimeField(auto_now=True) def __str__(self): return str(self.title) URLS: from django.conf.urls import url, include from django.contrib import admin from InvenTorrey.settings import base from django.conf.urls.static import static from games import urls as game_urls urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^^api/v1/', include(game_urls)), ] …