Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django.db.migrations.exceptions.CircularDependencyError
I have a problem with django migrations on empty DB. When, i want to migrate i have a circular dependency error. Circular dependency error between two apps that related by ForeignKeys /firstapp/models.py class Person(models.Model): genders_list = ( ('m', 'Male'), ('f', 'Female'), ) user_field = models.OneToOneField(User, on_delete=models.CASCADE) gender = models.CharField(max_length=1, choices=genders_list, default='m') phone_1 = models.CharField(max_length=25, verbose_name="Phone number") phone_2 = models.CharField(max_length=25, verbose_name="Phone number 2", blank=True) def __str__(self): return self.user_field.first_name + self.user_field.last_name class Doctor(Person): job_position = models.CharField(max_length=255, verbose_name="Job position") hospital_field = models.ForeignKey('hospital.Hospital', on_delete=models.SET_NULL, null=True, default=None,blank = True) seat_field = models.ForeignKey('hospital.Seat', on_delete=models.SET_NULL, null=True, default=None,blank = True) class Patient(Person): doctor_field = models.ForeignKey('Doctor', on_delete=models.SET_NULL, null=True, default=None) /secondapp/models.py class Hospital(models.Model): name = models.CharField(max_length=255, verbose_name="Name") description = models.TextField(verbose_name="Description") country = models.CharField(max_length=100, verbose_name="Country") city = models.CharField(max_length=100, verbose_name="City") address = models.CharField(max_length=255, verbose_name="Address") post_index = models.CharField(max_length=10, verbose_name="Post index", blank=True) main_doctor = models.ForeignKey('authoriz.Doctor', on_delete=models.SET_NULL, null=True,verbose_name="Main Doctor") work_phone = models.CharField(max_length=25, verbose_name="Work phone", blank=True) phone_1 = models.CharField(max_length=25, verbose_name="Mobile phone 1") email = models.EmailField(max_length=100, verbose_name="Email") calendar = models.ForeignKey('schedule.Calendar',verbose_name="calendar",null = True) def __str__(self): return self.name class Seat(models.Model): hospital_field = models.ForeignKey('Hospital', on_delete=models.CASCADE) number = models.CharField(max_length=255, verbose_name="Number",unique=True) def __str__(self): return self.number + '(' + self.hospital_field + ')' After python manage.py migrate Traceback Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/yarsanich/mydentist/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, … -
Can anyone just tell me what i should read or study?
I wanted to make a website, where a non-admin user can send data to the administrator through local area network, After having received data from different computers, The admin then process the data and send back the processed data to the users. (Trying to make a Voting System). -
How to convert to JSON a model with a OneToOneFIeld by means of serializer
I have the following Django model: class CustomUser(models.Model): user = models.OneToOneField(User) additional_field = models.CharField(max_length=30, default='', blank=True) def as_json(self): return dict( id=self.user.id, username=self.user.username, password=self.user.password, email=self.user.email, additional_field=self.additional_field) Along with a method to get all CustomUser: @api_view(['GET']) def get_all_users(request): # retrieve all CustomUser objects all_friends = CustomUser.objects.all() lst = [friend.as_json() for friend in all_friends] json_data = JSONRenderer().render(lst) return HttpResponse(json_data, content_type='application/json') I have also implemented the following serializer: class CustomUserSerializer(serializers.ModelSerializer): additional_field = serializers.CharField(source='customuser.additional_field') class Meta: model = User fields = ('id', 'username', 'password', 'first_name', 'last_name', 'email', 'additional_field') def create(self, validated_data): print(type(validated_data)) print(validated_data) profile_data = validated_data.pop('customuser', None) user = super(CustomUserSerializer, self).create(validated_data) self.create_or_update_profile(user, profile_data) return user def update(self, instance, validated_data): print(type(validated_data)) print(validated_data) profile_data = validated_data.pop('customuser', None) self.create_or_update_profile(instance, profile_data) return super(CustomUserSerializer, self).update(instance, validated_data) def create_or_update_profile(self, user, profile_data): print('CREATE OR UPDATE PROFILE') profile, created = CustomUser.objects.get_or_create(user=user, defaults=profile_data) if not created and profile_data is not None: super(CustomUserSerializer, self).update(profile, profile_data) However, I would like to be able to conver all my CustomUser to JSON but by means of its serializer (i.e. without the as_json method). Indeed, I've managed to deserialize different Django models by means of their serializer, but, because of the OneToOneField field, I have been unable to achieve it so far. -
create two different types of users
I want to create two different types of users, the first is Teacher the second is Student, note that each one of these models contain some shared fields that found in User model from django.contrib.auth.models and some different fields that I want to add. How can I do it in django. -
Django: how to override core handlers
I have made a custom middleware and if it throws exception, it is automatically handled by BaseHandler function get_response (django.core.handlers.base). My exception ObjectDoesNotExist, by default, is not handled and therefore a function handle_uncaught_exception takes care of it. But it considers all error as 500 Internal Server (even if it is a 400 Bad request) and returns default django error html template with 500 code. Here is my code: custom_middleware.py: class CustomMiddleware(object): """ custom middleware """ def process_request(self, request): try: code which throws ObjectDoesNotExist except ObjectDoesNotExist as e: code This automatically is handled by BaseHandler.get_response() So to solve the problem what I did was inherited the BaseHandler and override get_response function adding exception handler for my error and which gives a json response rather than HTML template. base.py from django.core.handlers.base import BaseHandler class ExceptionHandler(BaseHandler): def get_response(self, request): my code But this doesn't help as it calls the base class method even after overriding. Any help -
Django save behaving randomly
I have a Story model with a M2M relationship to some Resource objects. Some of the Resource objects are missing a name so I want to copy the title of the Story to the assigned Resource objects. Here is my code: from collector import models from django.core.paginator import Paginator paginator = Paginator(models.Story.objects.all(), 1000) def fix_issues(): for page in range(1, paginator.num_pages + 1): for story in paginator.page(page).object_list: name_story = story.title for r in story.resources.select_subclasses(): if r.name != name_story: r.name = name_story r.save() if len(r.name) == 0: print("Something went wrong: " + name_story) print("done processing page %s out of %s" % (page, paginator.num_pages)) fix_issues() I need to use a paginator because I'm dealing with a million objects. The weird part is that after calling fix_issues() about half of my resources that had no name, now have the correct name, while the other half still has no name. I can call fix_issues() again and again and every time more objects receive a name. This seems really weird to me, why would an object not be updated the first time but only the second time? Additional information: The "Something went wrong: " message is never printed. I'm using select_subclasses from django-model-utils to iterate over … -
How to pass optional keyword named group to views.py in Django?
I am working on a search filter of an ecommerce site. Current Situation: When user select each platform filter, the platform name will be appended to URL and display the filtered result. My approach: url.py url(r'^search/(?P<product_slug>[0-9a-z-]+)$', CustomSearchView(), name='search_result_detail'),enter code here url(r'^search/(?P<product_slug>[0-9a-z-]+)_(?P<platform_slug>[0-9a-z-]+)$', CustomSearchView(), name='search_result_platform'), url(r'^search/(?P<product_slug>[0-9a-z-]+)_(?P<platform_slug>[0-9a-z-]+)_(?P<platform_slug2>[0-9a-z-]+)$', CustomSearchView(), name='search_result_platform2'), url(r'^search/(?P<product_slug>[0-9a-z-]+)_(?P<platform_slug>[0-9a-z-]+)_' r'(?P<platform_slug2>[0-9a-z-]+)_(?P<platform_slug3>[0-9a-z-]+)$', CustomSearchView(), name='search_result_platform3'), Main Question: I didn't want to limit the filtering number. So if there are 20 platform filters, I need to create 20 URLs. Definitely it's not a smart way. Any other smart way to avoid creating a batches of URL? views.py def __call__(self, request, product_slug, platform_slug=None,platform_slug2=None,platform_slug3 = None ,platform_slug4 = None,platform_slug5 = None): if platform_slug is None: self.product_review_list = SearchResult.objects.filter(products__slug=product_slug) else: self.product_review_list = SearchResult.objects.filter(Q(products__slug=product_slug), Q(platform__slug=platform_slug)|(Q(platform__slug=platform_slug2)|Q(platform__slug=platform_slug3) |Q(platform__slug=platform_slug4)|Q(platform__slug=platform_slug5))) -
Writing a Sports League Program "The Django Way"
I'm coding for a large sports league in Django. I have separate tables for Sports, Teams, Schools, and Schedule. The Schedule model includes Home and Away Scores. This is a results-based app, not a scheduling one. My question is on recording results "The Django Way". I could create a Results model that saves wins and losses, but that feels like storing unnecessary data, and could be a problem if two users submit different scores for the same game. The alternate way is to use a query and calculate wins/losses every time it's called up. I'm up for the challenge, but am concerned that I'll start going towards a dead end. Here are my models, if that helps: from django.db import models from django.contrib import admin class Sports(models.Model): sport = models.AutoField(primary_key=True) sport_name = models.CharField(max_length=225, blank=True, null=True) class Meta: managed = True db_table = 'sports' def __str__(self): return self.sport_name class School(models.Model): school = models.AutoField(primary_key=True) school_name = models.CharField(max_length=225, blank=True, null=True) class Meta: managed = True db_table= 'school' def __str__(self): return self.school_name class SchoolAdmin(admin.ModelAdmin): fields = ('school_id', 'school_name') class Teams(models.Model): team = models.AutoField(primary_key=True) team_name = models.CharField(max_length=225, blank=True, null=True) sport_id = models.ForeignKey(Sports, models.DO_NOTHING, blank=True, null=True) division = models.CharField(max_length=225, blank=True, null=True) school = models.ForeignKey(School, models.DO_NOTHING, blank=True, … -
How to get a Google App Engine running locally
I'm trying to get a Python Google App Engine to run locally (macOS Sierra) and am having all sorts of trouble with and was wondering what I could possibly be missing. Please note this is my first foray into Python (usually develop with Ruby). I've downloaded Google App Engine sdk for python and followed the steps to get it up and running. After a few attempts I've placed it within the same directory as my App. I'm using Python 2.7.x which is what the App requires. I'm using virtualenv so I've initiated it like so: source bin/activate and try to run the app like so: dev_appserver.py --storage_path=../GAE-storage/ --port=9080 --log_level=info $* . When I try ti visit the page I get an error like: Traceback (most recent call last): File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__ self._update_configs() File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs self._registry.initialize() File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize import_func(self._modname) File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 19, in <module> from django.conf import settings ImportError: No module named django.conf INFO 2016-11-20 11:09:47,599 module.py:788] default: "GET / HTTP/1.1" 500 - So, to fix this issue I've downloaded Django manually and extracted it to app directory. Then it … -
Django zoho smtp server error
when i'm trying to send email from my website i get this error: raise SMTPServerDisconnected("Connection unexpectedly closed") SMTPServerDisconnected: Connection unexpectedly closed my settings.py EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.zoho.com' EMAIL_HOST_USER = 'info@mydomain.com' EMAIL_HOST_PASSWORD = '******' EMAIL_PORT = 587 -
Import error no module django
I am importing an module named "python_contextual_test_manager" in forms.py both python_contextual_test_manager and forms.py is in same directory from python_contextual_test_manager.main_runner import main as main_runner but it shows me the following error ImportError: No module named python_contextual_test_manager what to do? -
How to use underscore to separate named group in Django URL?
I am new to django field and would like to seek help from django masters. Now my URL has two named groups (product_slug and platform_slug) separated by "/" as below: /search/canon-eos-1d-x-mark-ii/dc-fever Current URL Config: url(r'^search/(?P[\w-]+)$', CustomSearchView(), name='search_result_detail'), url(r'^search/(?P[\w-]+)/(?P[\w-]+)$', CustomSearchView(), name='search_result_platform'), I would like to use underscore as separator to make the URL short and clean: /search/canon-eos-1d-x-mark-ii_dc-fever Seems it's not easy to use separator other than "/" to separate Named Groups. Are there any other solutions? Thanks all! -
virtualenv project vs django/rapidsms project
I am new to whole python django world and currently learning rapidsms. i am at a point where I installed virtualenvwrapper and created virtualenv for project mkvirtualenv projXYZ and workon projXYZ. I have installed django and rapidsms after this. So right now as per my understanding I only have pip, python and virtualenv installed on my local and all project specific tech is installed in virtual env created by name projXYZ. Is my understanding correct? After this as I am following tutorials I am to create new RapidSMS-django project from template. I am confused whether to create this project with same name as projectXYZ since I have virtualenv for project or Can it be other project name as well. -
Having a rest api and website in django working on same models
Im working on a project that needs a rest api and a web interface for doing same stuff. so my question is should i put both these interfaces in one django app or create separate apps for each and connect them somehow. -
DRF APIView move request validation to dispatch method using request.data
I've created a base api view, which extends from APIView, where I log response time, log request, and other common stuffs. Now, I also want to add request validation here, using the Serializer defined in sub-class Views. I thought the appropriate place is to put that in dispatch() method. But before I call API.dispatch() method, request.data is not prepared. So, that won't work. Can someone help me in right direction as to how to move validation to a single place? Here's the class structure: class BaseView(APIView): validation_serializer = None def dispatch(self, request, *args, **kwargs): # Some code here # How to use `validation_serializer` here, to validate request data? # `request.data` is not available here. response = super(BaseView, self).dispatch(request, *args, **kwargs) # Some code here return response class MyView(BaseView): validation_serializer = ViewValidationSerializer def post(self, request, *args, **kwargs): pass I thought another approach could be use decorator on the top of post() method. But if only there was an cleaner way, than putting decorators all across the project? Note: It's similar to the question here: Django - DRF - dispatch method flow. But as per the suggestion there, I don't want to just copy the entire dispatch method from DRF source code. -
Django: implement cascade field change?
models.py class ModelA(TimeStampedModel): is_active = models.BooleanField(default=True) class ModelB(TimeStampedModel): a = models.ForeignKey(ModelA) is_active = models.BooleanField(default=True) class ModelC(TimeStampedModel): a = models.ForeignKey(ModelA) is_active = models.BooleanField(default=True) class ModelD(TimeStampedModel): c = models.ForeignKey(ModelC) is_active = models.BooleanField(default=True) class ModelE(TimeStampedModel): d = models.ForeignKey(ModelD) is_active = models.BooleanField(default=True) What I want to implement: >> a = ModelA.objects.first() >> a.deactivate() result : all object's `is_active` field set False And if I execute, >> c = ModelC.objects.first() >> c.deactivate() result : Model C,D,E object's `is_active` field set False Is there any 'easy' way to implement this in Django? (using signal or inheritance etc) I want general way(not depending on specific Model, can be used in any class). Thanks -
rq-scheduler: how to view last run in django admin
Is there a way to know when is the last time rq-scheduler has run for a specific task in the Django Admin? Maybe another django admin app has to be installed? Thank you, Rami -
How to resolve TypeError: __init__() got an unexpected keyword argument '_MAX_LENGTH' in Django
This my models.py code.Can anyone let me know whats wrong with this code ? from django.db import models from unittest.util import _MAX_LENGTH class Album(models.Model): artist = models.CharField(_MAX_LENGTH=250) album_title = models.CharField(_MAX_LENGTH=500) genre = models.CharField(_MAX_LENGTH=100) album_logo = models.CharField(_MAX_LENGTH=1000) class Song(models.Model): album = models.ForeignKey(Album, on_delete = models.CASCADE) file_type = models.CharField(_MAX_LENGTH=10) song_title = models.CharField(_MAX_LENGTH=250) While runnin command python manage.py migrations music,I am getting this error Traceback (most recent call last): File "/home/sunil/workspace/DjangoApp1/manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 328, in execute django.setup() File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/usr/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/sunil/workspace/DjangoApp1/music/models.py", line 5, in <module> class Album(models.Model): File "/home/sunil/workspace/DjangoApp1/music/models.py", line 6, in Album artist = models.CharField(_MAX_LENGTH=250) File "/usr/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1081, in __init__ super(CharField, self).__init__(*args, **kwargs) TypeError: __init__() got an unexpected keyword argument '_MAX_LENGTH' -
Where is X-FRAME-OPTIONS: DENY coming from on Django site via nginx?
My Django site uses django-summernote in iframes, and is throwing this error: Multiple 'X-Frame-Options' headers with conflicting values ('SAMEORIGIN, DENY') encountered when loading 'http://example.com/summernote/editor/id_comment_text/'. Falling back to 'DENY'. I can't figure out where the DENY is coming from. In my Django project settings I have: MIDDLEWARE_CLASSES = ( ... 'django.middleware.clickjacking.XFrameOptionsMiddleware', ... ) which: "By default, the middleware will set the X-Frame-Options header to SAMEORIGIN for every outgoing HttpResponse." I also added this in my nginx.conf (from here): add_header X-Frame-Options SAMEORIGIN; Other possibly relevant info: The problem arose when I upgraded my server from Ubuntu 14.04 to 16.04, and by project's virtual environment from Python 3.4 to Python 3.5. The version of Django and django-summernote are still the same. How do I find the source of this DENY setting? -
Django ORM default values not applied to MySQL DB
I have a field in a Django model that looks like this: median = models.IntegerField(default=0) I would like this to be equivalent to a MySQL create table query like this: median INT DEFAULT 0 However, looking at my db in Sequel Pro, I see there is no default value set. Is there a way to change this behavior, or a smart workaround? My goal is to be able to insert values into the DB without using the ORM, and still benefit from the default values. -
Heroku deployment error : ImproperlyConfigured Django_Secret_key environment variable
I am deploying my django project to Heroku. But secret key issue keeps popping up! What could have been wrong? Any suggestions would be appreciated, thank you! State changed from crashed to starting Nov 20 16:37:53 heroku_app heroku/web.1: Starting process with command `gunicorn config.wsgi:application --env DJANGO_SETTINGS_MODULE='config.settings.production'` Nov 20 16:37:56 heroku_app heroku/web.1: State changed from starting to up Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:55 +0000] [4] [INFO] Starting gunicorn 19.5.0 Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:55 +0000] [4] [INFO] Listening at: http://0.0.0.0:46247 (4) Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:55 +0000] [4] [INFO] Using worker: sync Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:55 +0000] [10] [INFO] Booting worker with pid: 10 Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:55 +0000] [11] [INFO] Booting worker with pid: 11 Nov 20 16:37:56 heroku_app app/web.1: [2016-11-20 05:37:56 +0000] [10] [ERROR] Exception in worker process Nov 20 16:37:56 heroku_app app/web.1: Traceback (most recent call last): Nov 20 16:37:56 heroku_app app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 517, in spawn_worker Nov 20 16:37:56 heroku_app app/web.1: worker.init_process() Nov 20 16:37:56 heroku_app app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process Nov 20 16:37:56 heroku_app app/web.1: self.load_wsgi() Nov 20 16:37:56 heroku_app app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 132, in load_wsgi Nov 20 16:37:56 heroku_app … -
django+bootstrap: concatentating bootstrap_alert
I have the following code: {% if errmsg %} {% bootstrap_alert errmsg alert_type='danger' %} {% endif %} errmsg is supplied from the previous page I would like to extend the errmsg with some strings i.e. {% if errmsg %} {% bootstrap_alert "msg: %s" % errmsg alert_type='danger' %} {% endif %} Obvously, the above prints error: Could not parse the remainder: '%' from '%' what is the correct way to print message for bootstrap_alert? -
Using JSON dict in Django
I'm trying to access certain fields of information in JSON dict. My code is set up as the following: Views.py def viewIssues(request): r = requests.get(bucket_url) issue_payload = r.json() issue = json.loads(str(issue_payload)) context = { "issue_title": issue['issues']['title'], "issue_content": issue['issues']['content'], "title": "View Issues", } return render(request, "view_issues.html", context) str(issue_payload) gives me this: { 'search':None, 'count':1, 'filter':{ }, 'issues':[ { 'priority':'major', 'comment_count':0, 'utc_created_on':'2016-11-12 01:48:16+00:00', 'utc_last_updated':'2016-11-12 01:48:16+00:00', 'status':'new', 'title':'example issue', 'reported_by':{ 'is_staff':False, 'display_name':'display name', 'is_team':False, 'resource_uri':'/1.0/users/username', 'avatar':'https://bitbucket.org/account/username/avatar/32/?ts=1479493904', 'first_name':'firstname', 'username':'username', 'last_name':'lastname' }, 'is_spam':False, 'content':'blah blah', 'metadata':{ 'milestone':None, 'component':None, 'version':None, 'kind':'bug' }, 'local_id':1, 'created_on':'2016-11-12T02:48:16.052', 'resource_uri':'/1.0/repositories/username/supportal2016test/issues/1', 'follower_count':1 } ] } However when I try to use the json.loads and indices ['issues']['title'] and ['issues']['title'] I get an error: JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) I'm wondering if it's because the converted payload has quotations on each field (i.e. 'issues'). Any help would be much appreciated. -
heroku rejected django app push
git push staging feature/homepage:master Counting objects: 16, done. Delta compression using up to 4 threads. Compressing objects: 100% (15/15), done. Writing objects: 100% (16/16), 1.48 KiB | 0 bytes/s, done. Total 16 (delta 9), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: Usage: pip-diff [options] remote: remote: Traceback (most recent call last): remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 116, in remote: main() remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 112, in main remote: diff(**kwargs) remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 84, in diff remote: r1 = Requirements(r1) remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 29, in init remote: self.load(reqfile) remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 39, in load remote: for requirement in parse_requirements(reqfile, finder=finder, session=requests): remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 93, in parse_requirements remote: for req in req_iter: remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 192, in process_line remote: for req in parser: remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 93, in parse_requirements remote: for req in req_iter: remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 140, in process_line remote: opts, _ = parser.parse_args(shlex.split(options_str), defaults) remote: File "/app/.heroku/python/lib/python2.7/optparse.py", line 1402, in parse_args remote: self.error(str(err)) remote: File "/app/.heroku/python/lib/python2.7/optparse.py", line 1584, in error remote: self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg)) remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 284, in parser_exit remote: raise RequirementsFileParseError(msg) remote: pip.exceptions.RequirementsFileParseError: pip-diff: … -
Getting a 404 error when running my Django server for site
I get the error: Page not found (404) Request Method: GET Request URL: http://localhost:8001/ Using the URLconf defined in recipe_organizer.urls, Django tried these URL patterns, in this order: ^admin/ ^recipes/ ^media/(?P.*)$ The current URL, , didn't match any of these. It was working not too long ago but not nothing will post. Here is my urls.py file: from django.conf.urls import include, url from django.contrib import admin from django.conf import settings urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^recipes/', include('apps.recipes.urls')), url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ] Here is my settings(without the special key included): """ Django settings for recipe_organizer project. Generated by 'django-admin startproject' using Django 1.8. For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '-------------------------------------' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'apps.recipes', 'rest_framework', 'corsheaders', ) MIDDLEWARE_CLASSES = ( 'corsheaders.middleware.CorsMiddleware', …