Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Get Firestore realtime updates with Django websockets
I think I need to use Firestore realtime updates to keep a track of realtime updates made in Firestore via Django channels. I have created a basic chat application using Django Channels which saves user's messages in Cloud Firestore following this tutorial. I am new with both Django and Firstore and pretty much confused as to how to integrate Firstore realtime listener with Django websockets. Couldn't find any tutorial which uses both of them together. Is it possible to use any one and still get realtime updates, am I on the correct path or missing something? Any guidelines will be appreciated. -
Dynamic query in django with "|" character in WHERE clause and variable in tablename
I have a dynamic sql query running in my views.py and have already ran others that work fine. I am really worried about sql injections because this is a private website. However, the parameters in my And clause has the character "|" in it which throws the error Unknown column "X" in 'where clause' I have looked at solutions but they all use non dynamic query which then prohibits me from making the tablename a variable. Here is what I want: mycursor = mydb.cursor() assembly_name = "peptides_proteins_000005" group_id = 5 protein_id = "sp|P48740|MASP1_HUMAN" qry = "SELECT * FROM %s WHERE group_id = %i AND protein_id = %s" % (assembly_name, group_id, protein_id) mycursor.execute(qry) But this throws the error: mysql.connector.errors.ProgrammingError: 1054 (42S22): Unknown column 'sp' in 'where clause' However if I try doing something more along the lines of this, like the did in the previous questions I have seen: qry = "SELECT * FROM %s WHERE group_id = %i AND protein_id = %s" mycursor.exectue(qry, (assembly_name, group_id, protein_id)) I get the error: mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement Changing the %i to a %s fixes this problem but then I get the error: mysql.connector.errors.ProgrammingError: 1064 (42000): You have … -
I want to use url parameters as optional filters django rest framework
I have a django rest framework application and I want to use my url parameters as optional filtering for queryset it they are given in the url. Right now, i am trying to grab the parameters from the url and they are not grabbing, it is also then not applying the parameters as a filter. can someone help me wit this. urls: router.register(r'preferences', PreferenceUserViewSet, basename='Preference') router.register(r'preferences/(?P<namespace>\w+)', PreferenceUserViewSet, basename='Preference-namespace') router.register(r'preferences/(?P<namespace>\w+)/(?P<path>\w+)', PreferenceUserViewSet, basename='Preference-path') viewset: class PreferenceUserViewSet(viewsets.ModelViewSet): model = Preference serializer_class = PreferenceSerializer def get_permissions(self): if self.action == 'create' or self.action == 'destroy': permission_classes = [IsAuthenticated] else: permission_classes = [IsAdminUser] return [permission() for permission in permission_classes] @permission_classes((IsAuthenticated)) def get_queryset(self): namespace = self.request.query_params.get('namespace', None) path = self.request.query_params.get('path', None) print(namespace) print(path) queryset = Preference.objects.filter(user_id=1) if path is not None: queryset = Preference.objects.filter(user_id=1, namespace=namespace) if namespace is not None: queryset = Preference.objects.filter(user_id=1, namespace=namespace, path=path) return queryset -
Tempus Dominus Bootstrap 4: blank DateTimeInput field
I've developed a custom form using Tempus Dominus Bootstrap 4 in CDN When I create an object I can add a correct date and time but when I try to update an existing object the input field of the form is blank; I aspect to see the previous date and time. I don't understand where is the problem. What I've wrong? forms.py class FileUploadForm(forms.ModelForm): name = forms.CharField( max_length=50, help_text="<small>Write file name here. The name must be have max 50 characters</small>", widget=forms.TextInput( attrs={ "placeholder": "Titolo", "type": "text", "id": "id_title", "class": "form-control form-control-lg", } ), ) description = forms.CharField( max_length=200, help_text="<small>Write a short description here. The description must be have max 200 characters.</small>", widget=forms.Textarea( attrs={ "placeholder": "Descrizione", "type": "text", "id": "id_description", "class": "form-control", "rows": "2", } ), ) publishing_date = forms.DateTimeField( input_formats=['%d/%m/%Y %H:%M'], label="Data di pubblicazione", help_text="<small>Write data and hour of publication. You can use also a past or a future date.</small>", widget=forms.DateTimeInput( attrs={ "id": "publishing_date_field", 'class': 'form-control datetimepicker-input', 'data-target': '#publishing_date_field', } ), ) file = forms.FileField( help_text="<small>Upload the file here.</small>", widget=forms.ClearableFileInput( attrs={ "placeholder": "Carica il file", "type": "file", "id": "id_file", "class": "custom-file-input", } ), ) class Meta: model = FileUpload fields = [ 'name', 'description', 'publishing_date', 'file', ] views.py def createFile(request): … -
How to store data over time in Django ORM?
I would like to store numerical data that corresponds to a certain date, as in stock prices. Each stock would have a list of days and a corresponding price for that day. I am aware of Django's ArrayField, but that wouldn't work as a dictionary; I'd have to have two separate arrays with the indices of each day and price matching up. In theory a One:Many relationship between the stock and the day, with a One:One relationship beteen day and the price could work, but this seems very inefficient. Am I correct in thinking so? This is what some data might look like in pure Python appl = {Datetime.date(2000, 1, 1): 100, Datetime.date(2000, 1, 2): 200} googl = {Datetime.date(2010, 1, 1): 100, Datetime.date(2010, 1, 2): 200} #etc I'm using Python 3.6, Django 2.2 and PostgreSQL for the database. What is a way of accomplishing this? -
Can't get the val() of any child from Firebase to Django
I'm trying to connect a Django project to google firebase account using pip install Pyrebase Here is my config in the views.py: cred = credentials.Certificate("Cpanel/fostania-3b742-firebase-adminsdk-hk9hn-393fb87471.json") config = { "apiKey": "AIzaSyCTOTpYu25cyT7WuFRCE4lOFnCxXWHQsYg", "authDomain": "fostania-3b742.firebaseapp.com", "databaseURL": "https://fostania-3b742.firebaseio.com", "storageBucket": "fostania-3b742.appspot.com", } firebase = pyrebase.initialize_app(config) default_app = firebase_admin.initialize_app() print(default_app.name) I've created a service account credential and used the JSON file as you see in the code cred = credentials.Certificate("Cpanel/fostania-3b742-firebase-adminsdk-hk9hn-393fb87471.json") Also, added GOOGLE_APPLICATION_CREDENTIALS to envoirment variables. And now using this view only prints (None): @login_required def index(request): db = firebase.database() all_agents = db.child("cities").get().val() print(all_agents) return render(request, 'Cpanel/index.html') -
How to perform a double step Subqueries in Django?
I have the below models: class Group(models.Model): group_name = models.CharField(max_length=32) class Ledger(models.Model): ledger_name = models.CharField(max_length=32) group_name = models.ForeignKey(Group,on_delete=models.CASCADE,null=True,related_name='ledgergroups') class Journal(models.Model): By = models.ForeignKey(Ledger,on_delete=models.CASCADE,related_name='Debitledgers') To = models.ForeignKey(Ledger,on_delete=models.CASCADE,related_name='Creditledgers') Debit = models.DecimalField(max_digits=20,decimal_places=2,default=0) Credit = models.DecimalField(max_digits=20,decimal_places=2,default=0) As you can see the Journal model is related with the Ledger models with a Foreignkey relation which is further related with Group model. My scenario is kind of complex. I want to filter the Group objects and their balances (Balances are the difference between their total Debit and their total Credit). I want to filter the total Group names and the subtraction of total Debit and total Credit..(Debit and Credit are the fields of Journal model). Can anyone help me to figure out the above. I have tried Subqueries before in Django but haven't done a two step Subquery in Django. Any solution will be helpful. Thank you -
error in AUTH_USER_MODEL after upgrading Django
i am working on django 1.8 and python 2.7 then i upgraded my django to 2.2 and python to 3.6 but when i run python manage.py runserver i got error in terminal that show me: django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'users.User' that has not been installed i use AUTH_USER_MODEL = 'users.User' in setting.py no changes i made for the code but just i upgraded my django and python -
Django Unable to send CSV via POST request
I have an extremely minimal app, where the relevant view function is defined like so: def upload_payment(request): if request.method == "GET": return HttpResponse(content="foo", status=200) elif request.method == "POST": file = request.FILES['file'] decoded_file = file.read().decode('utf-8').splitlines() reader = csv.DictReader(decoded_file) for row in reader: print(row) return HttpResponse(content="done", status=200) The above is the relevant view method. Now I run: curl -X POST -H 'Content-Type: text/csv' -d @test_file.csv http://localhost:8000/invoice_admin/upload_payments/ I'm getting an error: <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="robots" content="NONE,NOARCHIVE"> <title>403 Forbidden</title> <style type="text/css"> html * { padding:0; margin:0; } body * { padding:10px 20px; } body * * { padding:0; } body { font:small sans-serif; background:#eee; color:#000; } body>div { border-bottom:1px solid #ddd; } h1 { font-weight:normal; margin-bottom:.4em; } h1 span { font-size:60%; color:#666; font-weight:normal; } #info { background:#f6f6f6; } #info ul { margin: 0.5em 4em; } #info p, #summary p { padding-top:10px; } #summary { background: #ffc; } #explanation { background:#eee; border-bottom: 0px none; } </style> </head> <body> <div id="summary"> <h1>Forbidden <span>(403)</span></h1> <p>CSRF verification failed. Request aborted.</p> <p>You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked … -
How to allow post request in django rest framework correctly?
How to allow post request in django rest framework correctly? Now I get an error while create POST request to api/v3/exchange/order (use POST) Traceback (most recent call last): File "/home/skif/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner response = get_response(request) File "/home/skif/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/skif/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/skif/.local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/home/skif/.local/lib/python3.6/site-packages/django/views/generic/base.py", line 69, in view return self.dispatch(request, *args, **kwargs) File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch response = self.handle_exception(exc) File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception self.raise_uncaught_exception(exc) File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch response = handler(request, *args, **kwargs) File "/home/skif/PycharmProjects/beex2/app_ccxt/external_api.py", line 44, in post return getattr(self, self.name)(request) File "/home/skif/.local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/home/skif/.local/lib/python3.6/site-packages/django/views/generic/base.py", line 69, in view return self.dispatch(request, *args, **kwargs) File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/views.py", line 478, in dispatch request = self.initialize_request(request, *args, **kwargs) File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/views.py", line 382, in initialize_request parser_context=parser_context File "/home/skif/.local/lib/python3.6/site-packages/rest_framework/request.py", line 160, in __init__ .format(request.__class__.__module__, request.__class__.__name__) AssertionError: The `request` argument must be an instance of `django.http.HttpRequest`, not `app_ccxt.external_api.ApiExternalCCXT`. [08/Jul/2019 15:40:31] "POST /api/v3/exchange/order HTTP/1.1" 500 44749 I try to change request instance to HttpRequest and nothing changed. my code in external_api.py: from django.shortcuts import render from django.http import HttpResponse … -
Integrate Coverall or Codecov in my application using Docker container
I've been trying to integrate code-coverage in my Django application.. The build is successfull and all the tests are successfull but when i check coveralls.io or codecov.io there is no data.. I have searched everything, added a .coveragerc but still nothing helps. Dockerfile FROM python:3.7-alpine MAINTAINER abhie-lp ENV PYTHONUNBUFFERED 1 COPY ./requirements.txt /requirements.txt RUN apk add --update --no-cache jpeg-dev RUN apk add --update --no-cache --virtual .tmp-build-deps \ gcc libc-dev musl-dev zlib zlib-dev RUN pip install -r /requirements.txt RUN apk del .tmp-build-deps RUN mkdir /app WORKDIR /app COPY ./app /app RUN mkdir -p /vol/web/media RUN mkdir -p /vol/web/static RUN adduser -D ABHIE RUN chown -R ABHIE:ABHIE /vol/ RUN chmod -R 755 /vol/web USER ABHIE docker-compose.yml version: "3" services: app: build: context: . ports: - "8000:8000" volumes: - ./app:/app command: > sh -c "python manage.py wait_for_db && python manage.py migrate && python manage.py runserver 0.0.0.0:8000" .travis.yml language: python python: - "3.6" services: - docker before_script: - pip install docker-compose - pip install coveralls - pip install codecov - docker-compose run --user='root' app chmod -R 777 . script: - docker-compose run app sh -c "coverage run --source=. manage.py test" - docker-compose run app sh -c "flake8" after_success: - coveralls - codecov .coveragerc [run] … -
Can't redirect to view using form action method
I'm trying to go to /show_columns/ from /app/chooser/ by setting form action in /app/chooser/ to /dostuff/ but it goes to /app/chooser/dostuff/ instead this is my form in html template <form action="{% url 'learning_logs:show_columns' request.fl "{{ fl }}" %}"> When I click on that submit button it takes me to /columns/extcsv/show_columns when I actually want to go to /show_columns. -
String field based on M2M field in same model
I need to fill a CharField based on M2M field (For grouping proposes). For that I overwrite the save method (for create and update cases). In update case, only works for old M2M selection. In the create case, shows me an error: "maximum recursion depth exceeded". I think the logic isnt taking the form params, but can't find how to access them. Here's my code: class Content(models.Model): specifications = models.ManyToManyField(Specification, blank=True) string_specs = models.CharField(max_length=250, null=True, blank=True) def save(self, *args, **kwargs): if self.pk: self.string_specs = " - ".join([str(element) for element in self.specifications.all().order_by('id')]) super().save(*args, **kwargs) else: self.string_specs = " - ".join([str(element) for element in self.specifications.all().order_by('id')]) super().save(*args, **kwargs) -
image filed return null [duplicate]
This question is an exact duplicate of: image filed returns null if you know how can i fix this,please help me...I have a model like this; I'm trying to create sign up with these fields: username first name last name email address profile image class User(AbstractUser): username = models.CharField(blank=True, null=True, max_length=50) Email = models.EmailField(_('email address'), unique=True) Address = models.CharField(max_length=100, default="") UserProImage = models.ImageField(upload_to='accounts/',blank=True, null=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['Email', 'first_name', 'last_name', 'Address', 'UserProImage'] def __str__(self): return "{}".format(self.username) def get_image(self, obj): try: image = obj.image.url except: image = None return image def perform_create(self, serializer): serializer.save(img=self.request.data.get('UserProImage')) and for this model I wrote a serializer like so: class UserCreateSerializer(ModelSerializer): Email = EmailField(label='Email Address') ConfirmEmail = EmailField(label='Confirm Email') class Meta: model = User fields = [ 'username', 'first_name', 'last_name', 'Address', 'UserProImage', 'Email', 'ConfirmEmail', 'password', ] extra_kwargs = {"password": {"write_only": True} } objects = PostManager() def __unicode__(self): return self.username def __str__(self): return self.username def validate(self, data): return data def perform_create(self, serializer): serializer.save(self.request.data.get('UserProImage')) return self.data.get('UserProImage') def validate_email(self, value): data = self.get_initial() email1 = data.get('ConfirmEmail') username = data.get('username') email2 = value if email1 != email2: raise ValidationError("Emails must match.") user_qs = User.objects.filter(email=email2) username_qs = User.objects.filter(username=username) if user_qs.exists(): raise ValidationError("This user has already registered.") if username_qs.exists(): raise … -
is it possible to calculate quantities with price in ManyToMany relation ship in django
i'm trying to create a POS(point of sale) when someone buying multi items for example : mac book ; 900$ ,quantity;3 > 900*3=2700$ , hp pro book;800$,quantity;2 > 800*2 = 1600 class Product(models.Model): product_name = models.CharField(max_length=30) price = models.PositiveIntegerField(default=0) def __str__(self): return self.product_name class Store(models.Model): items = models.ManyToManyField(Product) quantity = models.PositiveIntegerField(default=1) is it possible !? or if not is there another way to achieve the same result -
How to send responses in Wit.ai and integrate it with Django?
I've built a Watson bot previously. Their bot building interface has this section called "Dialog" where u could add multiple responses to a single intent trigger. However I fail to find anything like this in Wit.ai Some tutorials taught me to generate replies with IF ELSE statement, Also making ECHO bot. But then whats the point of this platform? If there is any other way to do it, and I'm unaware, please help. Also I need to integrate it with Django, is it possible? If yes, please share the sources. But most importantly how do I generate multiple replies like DialogFlow and Watson? -
Is there any resource on a environment setup for DJANGO and VueJS . I dont find much resources online can anyboody help me with that
I got some articles related to django and vue environment setup. But it isn't Much clear about how to set up environment and how do they interact with each other. An articles on medium which uses existing environment setup. -
How to supply an argument to an URL correctly in Django template?
I am trying to create an API endpoint that accepts the argument cc. The view for this endpoint in module api is: def cc_details(request, cc): return JsonResponse({'cc': cc}) The URL is: urlpatterns = [ path('api/cc_details/<int:cc>', api.cc_details, name='cc_details'), ] I am calling the URL from the template like this: async function get_cc_details(cc) { let url = new URL("{% absurl 'core:analyzer:cc_details' %}" + "/" + cc) const response = await fetch(url) const json = await response.json() console.log(json) } The custom absurl to return absolute URL is: from django import template from django.shortcuts import reverse register = template.Library() @register.simple_tag(takes_context=True) def absurl(context, view_name): request = context['request'] return request.build_absolute_uri(reverse(view_name)) However, when I try to navigate to the index page of my app, I get the following error: django.urls.exceptions.NoReverseMatch: Reverse for 'cc_details' with no arguments not found. 1 pattern(s) tried: ['api/cc_details/(?P[0-9]+)$'] It will work fine if I just manually go to http://127.0.0.1:8000/api/cc_details/123 for example. My guess is that I am not supplying the argument to the URL in JS function correctly. How can I fix that? -
How do they run these commands in python console within Django project?
How do they run these python commands in python console within their django project. Here is example. I'm using Windows 10, PyCharm and python 3.7. I know how to run the project. But when I run the project, - console opens, which gives regular input/output for the project running. When I open python console - I can run commands, so that they execute immidiately, but how do I run python console, so that I can type some commands and they would execute immediately, but that would happen within some project? Example from here: # Import the models we created from our "news" app >>> from news.models import Article, Reporter # No reporters are in the system yet. >>> Reporter.objects.all() <QuerySet []> # Create a new Reporter. >>> r = Reporter(full_name='John Smith') # Save the object into the database. You have to call save() explicitly. >>> r.save() # Now it has an ID. >>> r.id 1 -
Submit the form to django-ajax
I have an app for Django. a simple number converter from roman to decimal and vice versa. I did the convector itself, making it a module. I could not make an Ajax request so that everything was without an update. viewes.py from . import decroman def home(request): data = { 'title': 'Convector', } return render(request, 'convector/convector.html', data) def res(request): if request.method == "GET": if 'InputConvert' in request.GET: num = decroman.decroman(request.GET['InputConvert']) result = num.result data = { 'convert': request.GET['InputConvert'], 'result': result, 'title': 'Result', } return HttpResponse(result) # return render(request, 'convector/result.html', data) else: return HttpResponseRedirect('/') def res(request): if request.method == "GET": if 'InputConvert' in request.GET: num = decroman.decroman(request.GET['InputConvert']) result = num.result data = { 'convert': request.GET['InputConvert'], 'result': result, 'title': 'Result', } return HttpResponse(result) # return render(request, 'convector/result.html', data) else: return HttpResponseRedirect('/') In the beginning, the essence is that when you start, the home method is displayed. After filling and sending to HTML, a redirect to the page with the answer takes place. convector.html <form action="/result/" method="get" class="form-group"> <div class="form-row"> <div class="form-group col-md-5"> <div class="form-group"> <label for="InputConvert">Enter numbers</label> <textarea class="form-control" id="InputConvert" rows="10" required name="InputConvert"></textarea> </div> </div> <button type="submit" class="btn btn-primary">Converting</button> <div class="form-group col-md-5"> <label for="OutputConvert">Convert</label> <textarea class="form-control" readonly id="StaticResult" rows="10"></textarea> </div> </div> </form> … -
How do I set up a virtualenv that I've inherited
I've inherited a virtualenv and need help getting it running on MacOSX. There's no documentation provided so I'm not sure if it is complete, but need help getting it going. I need help making sure the virtualenv is complete with all dependencies, database, etc. Project should be: Python 2.7 Django 1.3 PostgreSQL Looks lik I can get the virtualenv activated by: $ cd app $ source bin/activate However, doesn't look like it's using Python from within the virtualenv: $ which python /usr/bin/python I've also tried: echo $PATH /virtualenv/app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin $ pip freeze lists out global packages, not ones originating from within the virtualenv Thanks in advance. Here are the directories and files contained within the virtualenv: |-app |---bin |---include |-----python2.7 |---lib |-----Django-1.3 |-------django |---------bin |-----------profiling |---------conf |-----------app_template |-----------locale |-----------project_template |-----------urls |---------contrib |-----------admin |-------------locale |-------------media |---------------css |---------------img |-----------------admin |-----------------gis |---------------js |-----------------admin |-------------templates |---------------admin |-----------------auth |-------------------user |-----------------edit_inline |-----------------includes |---------------registration |-------------templatetags |-------------views |-----------admindocs |-------------locale |-------------templates |---------------admin_doc |-------------tests |-----------auth |-------------fixtures |-------------handlers |-------------locale |-------------management |---------------commands |-------------tests |---------------templates |-----------------registration |-----------comments |-------------locale |-------------templates |---------------comments |-------------templatetags |-------------views |-----------contenttypes |-------------locale |-----------csrf |-----------databrowse |-------------plugins |-------------templates |---------------databrowse |-----------flatpages |-------------fixtures |-------------locale |-------------templatetags |-------------tests |---------------templates |-----------------flatpages |-----------------registration |-----------formtools |-------------locale |-------------templates |---------------formtools |-------------tests |---------------templates |-----------------formwizard |-----------gis |-------------admin |-------------db |---------------backend |---------------backends |-----------------mysql |-----------------oracle |-----------------postgis |-----------------spatialite |---------------models … -
It is possible to associate f keys (F1 F2 F3 ecc) to a link in template?
Is possible use f key to open specific link in django? I'm using keydowm $(document).ready(function(){ $("body").keydown(function(key) { if (key.which == 113) { // F2 key // here my link like {% url 'test' %} } }); }); TY -
how woul i get rid off this error "OSError: [WinError 123] The filename,"
Am creating a project, When I run the server I get the error named "OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect", but before this there is another error which pops up "ModuleNotFoundError: No module named 'dep.urls' ". I have tried this several times by just creating project, an app and mapping to the urls without writting any code and run it but i get the same error above Am using django 2.2.3, python 3.6.8 and mysql 5.7.26. In the previous version of django(2.1.8) was working fine, I have tried to google a lot what I have found is that in the newer version of django there is the new way of mapping to the urls. Am pretty sure that the solution of my problem is in this link. When I open the described file, I don't find where to edit, what is being said is not available in the file. Please help!! urls from django.contrib import admin from django.urls import path,include urlpatterns = [ path('',include('dep.urls')), path('admin/', admin.site.urls), ] -
django filter through object after loop in template
I have a page that displays a snapshot of projects in a list of boxes, each box has project owner, title date, that kind of thing, there is also a window within that separates the updates into 7 categories, the updates are in a separate table. Looping through the projects is fine, but the updates come from all the projects. How do I filter out the other projects? I can post my code, but I have done this 2 or 3 times in the past month with no response so suspecting that my structure is completely wrong -
I need help in converting urlpatterns url to their path equivalents
I am helping a friend with a project and I am having trouble converting urlpatterns url to their path equivalents. Any help? I've managed the first part. `path('store', views.product_list, name='product_list'),` But the rest seems challenging urlpatterns = [ url(r'^store', views.product_list, name='product_list'), url(r'^(?P<category_slug>[-\w]+)/$', views.product_list, name='product_list_by_category'), url(r'^(?P<id>\d+)/(?P<slug>[-\w]+)/$', views.product_detail, name='product_detail'), ]