Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Two Django apps with the same name
I want to use the apps from this library https://github.com/andreynovikov/django-rated-reviews in my Django project. To do so, I need to add 'reviews' to INSTALLED_APPS. INSTALLED_APPS = ( ... 'reviews', ... ) The problem is that I already have a (custom) app called 'reviews'. What can I do? Do I have to change my app name? -
Django excluding an article from query
I have a query set called most_viewed, and it is a list of just one element. I want to exclude this in the other articles section as this will be in the main section. The error I receive is "Not enough values to unpack". Here is the code of my view. How do I go about fixing this? def home_view(request): title = 'Home' most_viewed = Post.objects.order_by('-views')[0:1] articles = Post.objects.all().exclude(most_viewed).order_by('-date_posted')[0:3] -
how to rendering the value of form in modeformset_factory with foreignkey
im still learning about django and i decide to have modelformset with a form that connect to foreign key. here is my model class Data_Nilai(models.Model): wali_kelas = models.ForeignKey(Data_Guru, on_delete=models.CASCADE, null=True) mapel = models.ForeignKey(Data_Mapel, on_delete=models.CASCADE, null=True) siswa = models.ForeignKey(Data_Siswa ,on_delete=models.CASCADE, null=True) tugas = models.CharField(max_length=3) uts = models.CharField(max_length=3) uas = models.CharField(max_length=3) def __str__(self): return "Nilai {}: {} ".format(self.mapel, self.siswa) class Data_Guru(models.Model): user = models.OneToOneField(User,limit_choices_to= {'groups__name': "guru"},null=True, on_delete=models.CASCADE, blank=True) nip = models.IntegerField(null=True, unique=True) nama = models.CharField(max_length=255, null=True) tgl_lahir = models.DateField() alamat = models.CharField(max_length=255, null=True) foto = models.ImageField(default='profile.png', null=True, blank=True) mapel = models.ManyToManyField(Data_Mapel) def __str__(self): return self.nama here is my form class Ubah_Nilai(forms.ModelForm): class Meta: model = Data_Nilai fields = ['siswa', 'mapel', 'tugas', 'uts', 'uas'] widgets = { 'tugas': forms.TextInput(attrs={'size': 2}), 'uts': forms.TextInput(attrs={'size': 2}), 'uas': forms.TextInput(attrs={'size': 2}) } My View def nilaiDetailView(request, pk): mapel = Data_Mapel.objects.get(pk=pk) nilaiformset = modelformset_factory(Data_Nilai,form=Ubah_Nilai,extra=0) if request.method == 'POST': formset = nilaiformset(request.POST, queryset=Data_Nilai.objects.filter(mapel_id=mapel.id, wali_kelas_id=request.user.data_guru.id)) print(formset.errors) print(request.POST.get('form-1-siswa')) if formset.is_valid(): nilai = formset.save(commit=False) print(formset) formset.save() return redirect('dashboard:nilai_detail',pk) formset = nilaiformset(queryset=Data_Nilai.objects.filter(mapel_id=mapel.id, wali_kelas_id=request.user.data_guru.id)) context = { 'formset':formset, } return render(request, 'guru/nilai/nilai_detail.html', context) and this is how i render my form {{formset.management_form}} {% for form in formset %} {{form.id}} <tr> <td>{{forloop.counter}}</td> <td>{{form.siswa}}</td> <td>{{form.mapel}}</td> <td>{{form.tugas}}</td> <td>{{form.uts}}</td> <td>{{form.uas}}</td> </tr> {% endfor %} and this is the display … -
Django REST Framework - Change ID Format
I am currently playing around with Django + Django REST Framework to build an API layer. A question I was curious about is if it's possible to change the id layout. Currently my model looks something like this: class Thing(models.Model): name = models.CharField(max_length=100) class ThingContainer(models.Model): name = models.CharField(max_length=100) things = models.ManyToManyField(Thing) This means that DRF (using ModelViewSet and ModelSerializer) automatically generates API endpoints like /things/1 or /thing_containers/2. I was wondering if there is a neat trick to change the format of the outward-facing ID. So instead of /things/1 it would be /things/YXBwOi8vdGhpbmcvMQ== which is the base64 encoding of app://things/1. I am aware that I could change the key of the model itself into a CharField and enforce that format on the DB level. However that comes with its own set of performance issues and other caveats. -
Unique constraint failed - redirect view?
I managed to get the below code limited to 1 user review per restaurant and it works great using the class meta "unique together" class UserReview(models.Model): # Defining the possible grades Grade_1 = 1 Grade_2 = 2 Grade_3 = 3 Grade_4 = 4 Grade_5 = 5 # All those grades will sit under Review_Grade to appear in choices Review_Grade = ( (1, '1 - Not satisfied'), (2, '2 - Almost satisfied'), (3, '3 - Satisfied'), (4, '4 - Very satisfied'), (5, '5 - Exceptionally satisfied') ) restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE) user_review_grade = models.IntegerField(default=None, choices=Review_Grade) # default=None pour eviter d'avoir un bouton vide sur ma template user_review_comment = models.CharField(max_length=1500) posted_by = models.ForeignKey(User, on_delete=models.DO_NOTHING) class Meta: unique_together = ['restaurant', 'posted_by'] I now realise that I need to update my view so that is this constraint is failed I am taken to an error page, but I can't find how, any guidance would be appreciated View: class Reviewing (LoginRequiredMixin, CreateView): template_name = 'restaurants/reviewing.html' form_class = UserReviewForm # Get the initial information needed for the form to function: restaurant field def get_initial(self, *args, **kwargs): initial = super(Reviewing, self).get_initial(**kwargs) initial['restaurant'] = self.kwargs['restaurant_id'] return initial # Post the data into the DB def post(self, request, restaurant_id, … -
I am trying to intergrate mpesa payment api to dynamically pass the store price and the correct response
i have been trying to intergrate mpesa api and make my payment dynamicaly i managet to see the correct value in my cart on my phone stk push but on the web browser i get an error local variable 'order' referenced before assignment and the console gives me a success message without me incorrectly putting in my pin, thank you please please help me solve this i am still a newbiee in PYTHON def mpesaToken(request): ckey = 'hOdosm1nU1tXMsT0yPTGjnHDgIUSxx8z' csecret = 'mrgGSIdbDOZaVrZl' apiurl = 'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials' r = requests.get(apiurl, auth=HTTPBasicAuth(ckey, csecret)) mptoken = json.loads(r.json) valida = mptoken['access_token'] return HttpResponse(valida) def lipaOnline(request): if request.user.is_authenticated: customer = request.user.customer order, created = Order.objects.get_or_create(customer=customer, complete=False) items = order.orderitem_set.all() cartItems = order.get_cart_items else: items = [] accesstoken = MpesaToken.valida apiurl = "https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest" headers = {"Authorization":"Bearer %s" % accesstoken} request = { "BusinessShortCode": Lipa.bscode, "Password": Lipa.decode_pass, "Timestamp": Lipa.lipatime, "TransactionType": "CustomerPayBillOnline", "Amount": order.get_cart_total, "PartyA": 254702672666, "PartyB": Lipa.bscode, "PhoneNumber": 254702672666, "CallBackURL": "https://sandbox.safaricom.co.ke/mpesa/", "AccountReference": "HAC", "TransactionDesc": "testeltd"} response = requests.post(apiurl, json=request, headers=headers) return HttpResponse('Success') print(request) -
How to create or reusing in python a token based DRCP connection to an Orcale database saving that Token in a Django Model inside postgres
I am trying to figure out how it is possible to use a tokenbased (not username and password) authorization method to create or reuse DRCP connections from one djangobased Python WSGI Webapplication to a remote Oracle database. The token for connecting to that Oracle DB should be stored inside a local postgresql database where all django models of that Web-Application is stored. I was able to create a "Hello World" Python programm connecting to the Oracle database using user name and password. Lets have a look to a picture I found some nice information here: https://oracle.github.io/python-cx_Oracle/samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html#pooling Persistent DB Connection in Django/WSGI application Django multiple dynamic databases after server startup Interprocess communication in Python https://community.oracle.com/thread/3583799 https://blogs.oracle.com/opal/python-cxoracle-and-oracle-11g-drcp-connection-pooling Create Django token-based Authentication Token Based Authentication in Django But the missing link is missing. How to create and use that token for allowing that webapplication from that server to connect to Oracle DB and to some work, without telling the webapplication admin any Oracle DB accounts or asking the current Webapplication for oracle account name and password? -
Issue with Connecting Django to Postgresql database
When I try to connect my app to postgresql db I always get this same error: django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'sqlite3' Here is my code in settings DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'mydb', 'USER': 'postgres', 'PASSWORD': 'pass123', 'HOST': 'localhost', 'PORT': '5432' } } I am using django version 3.0.2 and my psycopg2 version 2.8.5 . I did downgrade to earlier version of django and still the problem persists. Also my python version is 3.8. I tried doing this too DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'mydb', 'USER': 'postgres', 'PASSWORD': 'pass123', 'HOST': 'localhost', 'PORT': '5432' } } I thought it was the issue with the virtual env so I decided to perform on other projects too but still does not work. Can anyone please help me. -
django model form saving data to multiple models
I have a Custom User model with a team field. I also have a Team model with a ManyToManyField for the Custom Users. I have a template that allows a user to create a team using whatever Team Name they want. Upon creation, I want that user's Team to be assigned but the team primary key isn't created until the Team is created so how do I get that primary key id into the Custom User model? My direction of thought is that I would perform a user save after the "create-team" form save in the views, but I'm not sure how to do that. models.py class Team(models.Model): team_id = models.BigAutoField(auto_created=True, primary_key=True) team_name = models.CharField(max_length=35, null=False, default='YourTeam') team_type = models.CharField(choices=MEMBERSHIP_CHOICES, default='Free', max_length=30) num_users = models.IntegerField(default=1) emails = models.ManyToManyField('CustomUser', related_name='teamemails') class CustomUser(AbstractUser): username = None first_name = models.CharField(max_length=255, unique=False, verbose_name='first name') last_name = models.CharField(max_length=255, unique=False, verbose_name='last name') email = models.EmailField(max_length=255, unique=True) team = models.ForeignKey(Team, on_delete=models.SET_NULL, null=True, blank=True, related_name='userteam') team_leader = models.BooleanField(default=False) team_member = models.BooleanField(default=False) forms.py class CreateTeamForm(forms.ModelForm): team_name = forms.CharField(label='Team Name', required=True) class Meta: model = Team fields = ['team_name'] views.py @verified_email_required def create_team(request): template = 'users/create_team.html' if request.method == "POST": form = CreateTeamForm(request.POST) if form.is_valid(): form = form.save(commit=False) form.team_name = … -
My custom django signup form is showind errors before i even type anything thing is there a way to only show errors after trying to submit it
{% csrf_token %} Sign Up {{form.username.errors}} {{form.email.errors}} {{form.password1.errors}} {{form.password2.errors}} Have an account? Log in -
How to build table with for and if conditions in following way
i want to get such table: This is example A i want to achieve: Years Score Score2 2015 20 56 2014 30 67 2013 56 65 So far i did the table : <table> <tr> <th>Years</th> <th>Score</th> <th>Score2</th> </tr> {% for year in years %}<tr><td>{{ year }}</td>{% endfor %}</tr> {% for ab in a.0 %}{% if ab > 30 %}<td class="blue"> {{ab}}</td>{% elif 10 > ab %} <td class="yellow">{{ab}}</td>{% else %} <td class="red"> {{ab}}</td>{% endif %}{% endfor %} {% for ac in c.0 %}{% if ac > 80 %}<td class="blue"> {{ac}}</td>{% elif 1 > ac %} <td class="yellow">{{ac}}</td>{% else %} <td class="red"> {{ac}}</td>{% endif %}{% endfor %} </table> But it does not work. How to achieve example A ? -
Django template, display list of links as just links (remove list)
The problem I am using Django with allauth to facilitate social logins. The allauth standard template includes social logins via: {% include "socialaccount/snippets/provider_list.html" with process="login" %} However, this displays a list of a tags with bullet points on the page like: Facebook Google I would like to display the items as just a tags and not as a list. What I've tried I have tried: {% for social in "socialaccount/snippets/provider_list.html" %} {{ social }} {% endfor %} But this returns individual letters of the link address! Like: s o c i a l a c c o u n t / s n i p p e t s / p r o v i d e r _ l i s t . h t m l Could somebody point me in the right direction as to how to show the social links without displaying them as a list with bullet points? -
Can i change column type in database without updating Django model?
I have a django project which has created models for example: from django.db import models class Person(models.Model): title = models.CharField(max_length=30) description = models.CharField(max_length=30) This creates table: CREATE TABLE myapp_person ( "id" serial NOT NULL PRIMARY KEY, "title" varchar(30) NOT NULL, "description" varchar(30) NOT NULL ); Now i'm wondering can i change the column type to "LONGTEXT" without having to change the model? Would this cause an error? I don't have access to django code but i have access to database and i'm importing data, and values are more than 30 characters. -
Reverse for 'category' with arguments '('',)' not found.But category was working before making the profile tamplate
this web page is made by django. i am using CustomUser for the users athorization. the detail error can be found in the pastebin before adding the profile template it was working fine. the page is going to show a blog with search and category option and blog list. category option link is working and showing the relevant post list. there are 2 django apps i am making under a django project. this is the blogapp/views.py: def Search(request): query=request.GET['query'] if len(query)== 0: object_list = Post.objects.none() messages.warning(request,"Your search is query is empty") else: object_listTitle=Post.objects.filter(title__icontains=query) object_listContent=Post.objects.filter(description__icontains=query) object_list=object_listTitle.union(object_listContent) if len(query) > 100: messages.warning(request,"Your search query is too big") params={'object_list':object_list,'query':query} return render(request,'search.html',params) class BlogappListView(ListView): model = Post paginate_by=2 template_name = 'home.html' class BlogappPostView(DetailView): model = Post template_name = "post_detail.html" class BlogappCreateview(LoginRequiredMixin,CreateView): model = Post template_name = "post_new.html" form_class=PostForm login_url='login' def form_valid(self,form): form.instance.author=self.request.user return super().form_valid(form) class BlogappUpdateView(LoginRequiredMixin,UserPassesTestMixin,UpdateView): model = Post template_name = "post_edit.html" form_class=PostForm login_url='login' def test_func(self): obj=self.get_object() return obj.author==self.request.user class BlogappDeleteView(UserPassesTestMixin,DeleteView,LoginRequiredMixin): model = Post template_name = "post_delete.html" success_url=reverse_lazy('home') login_url='login' def test_func(self): obj=self.get_object() return obj.author==self.request.user def CategoryList(request): category_list=Category.objects.all(Category) return render(request,'category_list.html',{'category_list':category_list}) def CategoryDetail(request,pk): category = get_object_or_404(Category, pk=pk) post=Post.objects.filter(category=category) return render (request, 'post_category.html', {'category': category,'post':post}) this is the accounts/view.py: class SignUpView(CreateView): form_class=CustomUserCreationForm success_url=reverse_lazy('login') template_name='signup.html' accounts/urls.py: urlpatterns = … -
How to reset deleted CSRF Token. React, Django
I creating Website with React and Django. I getted csrf token from cookie File. And then think sudden deletes cookie files in user. How get next csrf token for use in website. -
Can't get parameters from URL. Django
Few days ago I started to learn Django. I have a problem with URL parameter. My views.py function: def hotel(request, id): return HttpResponse(id) My urls.py code: re_path(r'^hotel/(?P<id>)[\d]/$', views.hotel) And when I load the page like http://127.0.0.1:8000/hotel/4/. HttpResponse shows me nothing. id = None. Why? How can I take this id == 4? -
How do i count an annotate list - SQL error in Django queryset
Hello i am trying to count how many actors are in specific region based on zip codes queryset = Actor.objects.annotate(region_zip=Left('user__zip_code', 2)) \ .annotate(region_name=Subquery(ZipCode.objects.filter(code=OuterRef('region_zip')).values('region_id')[:1])) \ .values('region_name').annotate(count=Count('region_name')).order_by('-count') the models are like that (hope i am not missing something) class ZipCode(models.Model): """ Model for zip codes per region """ region = models.ForeignKey(Region, on_delete=models.CASCADE, related_name='zip_codes') code = models.CharField(max_length=10) def __str__(self): return self.code class Actor(Principal): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='actor') class User(AbstractUser): email = models.EmailField(_('email address'), unique=False, db_index=True) gender = models.CharField(max_length=1, choices=AVAILABLE_GENDERS, blank=True) street_address = models.CharField(max_length=254, blank=True) zip_code = models.CharField(max_length=10, blank=True) city = models.CharField(max_length=100, blank=True) country = models.ForeignKey(Country, null=True, default=None, on_delete=models.SET_NULL, related_name='country_users') state = models.CharField(max_length=254, blank=True) but i get this error: django.db.utils.OperationalError: (1055, "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'actor_db.accounts_user.zip_code' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by") if i use this as a queryset i get a list for every actor and his/hers region queryset = Actor.objects.annotate(region_zip=Left('user__zip_code', 2)) \ .annotate(region_name=Subquery(ZipCode.objects.filter(code=OuterRef('region_zip')).values('region_id')[:1])) \ .values('region_name') I think that the problem is in .annotate(count=Count('region_name')) but i can not find out what it is. Any recomendations ? -
Django Rest Framework Calculations in Serializer?
I'm working with a finance application, and due to the way that floating point math works, have decided to store all values in the database as cents (so dollar amount * 100). I have been banging my head against a wall to get the serializer to perform two calculations for me. On create/update accept a float value but then before saving to the database do value*100. Then on get, do value/100. I got it half working using a SerializerMethodField, but that seemed to remove my ability to do create/update actions. I also at one point had something that kind of worked for create/update by changing the serializer.save() method in the view and adding an IntegerField validator on the field, but then that broke the SerializerMethodField. In short, I'm stuck. lol Here is my very simple model: class Items(models.Model): user = models.ForeignKey( 'CustomUser', on_delete=models.CASCADE, ) name = models.CharField(max_length=60) total = models.IntegerField() My views for this item: class GetItems(generics.ListCreateAPIView): serializer_class = ItemsSerializer permission_classes = [permissions.IsAuthenticated, IsAuthorOrDenied] user = serializers.HiddenField(default=serializers.CurrentUserDefault(), ) def get_queryset(self): user = self.request.user return Items.objects.filter(user=user) def perform_create(self, serializer): serializer.save(user=self.request.user) class SingleItem(generics.RetrieveUpdateDestroyAPIView): serializer_class = ItemsSerializer permission_classes = [permissions.IsAuthenticated, IsAuthorOrDenied] user = serializers.HiddenField(default=serializers.CurrentUserDefault(), ) def get_queryset(self): user = self.request.user return Items.objects.filter(user=user) def … -
Django class Media including js to the button of the page
I am developing a widget and I need to include the static fields to it. class IconPickerWidget(forms.TextInput): class Media: css = {'all': ( "https://cdn.jsdelivr.net/npm/uikit@3.4.0/dist/css/uikit.min.css", 'https://fonts.googleapis.com/icon?family=Material+Icons', 'widget/css/style.css',),} js = ("https://code.jquery.com/jquery-3.4.1.min.js", 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', 'https://cdn.jsdelivr.net/npm/uikit@3.4.0/dist/js/uikit.min.js', 'https://cdn.jsdelivr.net/npm/uikit@3.4.0/dist/js/uikit-icons.min.js', 'widget/js/js.js') def render(self, name, value, attrs=None, **kwargs): super().render(name, value, attrs) flat_attrs = flatatt(attrs) atr_id = attrs['id'] html = f' <input {flat_attrs} value="{value}" type="text" class="form-contol use-material-icon-picker" id="{atr_id}" name="{name}"> ' return mark_safe(html) But there is a problem , my js in not working because this should be called after element, is there any way to mark this, so the widget.js is on buttom of the body ? -
Django if the user is active
How do i know if the user is active? after the user sign-up and sign-in his/her account, how do i know if that user is active? i have this in my html {% if user.is_active %} <a><span class="fa fa-send-o mbr-iconfont mbr-iconfont-btn"> </span>{{user}}</a></div> {%else%} <span class="fa fa-send-o mbr-iconfont mbr-iconfont-btn"><</span>Login</a></div> {%endif%} it doesnt work, this is my code in my login def loginpage(request): if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] post = User.objects.filter(username=username) if post: username = request.POST['username'] request.session['username'] = username return render(request, 'index.html') else: return render(request, 'login.html') return render(request, 'login.html') and this is my sign-up def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.is_staff=True form.save() return redirect('index') else: form = SignUpForm() return render(request, 'signup2.html', {'form': form}) -
how can I remove operational error when I am changing my database setup from postgresql to sqlite3
first I was working on postgre and it was working properly but when I change database setup in settings.py to sqlite3 and after runserver I am getting this error . any help?strong text -
How can I scrape dynamic data from internet and display it on my webpage?
The content should change every time I load my webpage like displaying the latest news. I am using Django to build a webpage. I have tired scrapy, but the data gets saved on .json file and I don't know how to use it on HTML file. I am new to web scraping and web development so I don't have an idea. -
How should I write a Middleware to set local timezones for different users in Django
I have a Django to-do list app. Users can create to-dos and add due dates and a whole lot more. So there are numerous occasions where I need to make use of DateTime objects. Now, I want this DateTime information to be local to the end-user depending on where that person is using the app from. By reading Django's docs here: docs on TimeZones, I have understood that I need to make a Middleware and also a view function to get the user's preferred timezone and activate it using timezone.activate(). Let's assume that I am allowing users to select their preferred timezone using a form. Let's say the form looks like this Class TimeZoneForm(forms.Form): time_zone = forms.CharField(default="UTC", max_length=100) # Using a string here might not be a good idea, but let's use this for simplicity As shown I will be assuming that UTC is the default for everyone. So now, let's say a user changes their timezone to "US/Pacific". The best I currently am able to do now is make my view function call the timezone.activate() function. Let's take a look: # views.py from django.utils import timezone import pytz from .forms import TimeZoneForm def user_prefs_view(request): if request.method == "POST": tz_form … -
Django CharFIeld with unique=True update error "Instance with this Name already exists"
I'm building a Django project for a client that requires me to not user a simple form.save() method to update a model field. Basically, it looks like this: I have this model with a CharField who has unique=True: # models.py class Course(models.Model): name = models.CharField(max_length=20, unique=True) other_field = models.CharField(max_length=10, null=True) def __str__(self): return self.name That model has a form in forms.py: # forms.py class CourseCreateForm(forms.ModelForm): class Meta: model = Course fields = ['name', 'other_field'] I need to update this field through a function view (can't be class based in this scenario. Of course, literally it can, but for my student's project requirements it can't be) and I can't use the simple form.save() function, so I need to do the full update code as if it was a normal form: # views.py def course_update(request, pk): course = Course.objects.get(pk=pk) course_queryset = Course.objects.filter(pk=pk) if request.method == "POST": form = CourseCreateForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] other_field = form.cleaned_data['other_field'] course_queryset.update(name=name, other_field=other_field) # <-- Where I try to update else: print(form.errors) return HttpResponseRedirect('../') else: form = CourseCreateForm(instance=course) context = { "form": form, } return render(request, 'base/course_update.html', context) When I try to only update the other_field, the change isn't made and in the formerrors I receive … -
Main picture missing in djangocms-light-gallery
I encountered a problem using the djangocms-light-gallery from https://pypi.org/project/djangocms-light-gallery/. After following the installation steps described in the above posted link, everything seemed to work as expected at first sight. The plugin appears as "Light Gallery" among the other components, thumbnails are displayed correctly, the gallery view opens, etc. The only thing that is missing is the main picture in gallery view. I have no idea how to fix this.. I receive the following error message: Page not found (404) Request Method: GET Request URL: http://localhost:8000/en/mypage/filer_public/e8/59/e859299d-5408-4f37-bedc-6005db1833a8/mypicture.jpg/ Raised by: cms.views.details Using the URLconf defined in mypage.urls, Django tried these URL patterns, in this order: en/ ^jsi18n/$ [name='javascript-catalog'] ^static/(?P<path>.*)$ en/ ^admin/ en/ ^ ^cms_login/$ [name='cms_login'] en/ ^ ^cms_wizard/ en/ ^ ^(?P<slug>[0-9A-Za-z-_.//]+)/$ [name='pages-details-by-slug'] en/ ^ ^$ [name='pages-root'] en/ ^ ^$ [name='home'] en/ ^sitemap\.xml$ ^media/(?P<path>.*)$ The current path, /en/mypage/filer_public/e8/59/e859299d-5408-4f37-bedc-6005db1833a8/mypicture.jpg/, didn't match any of these. Can someone help?