Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can not log in with Django, Attribute Error: AnonymousUser' object has no attribute '_meta'
I am trying to sigin my user in, the error I keep getting is an AttributeError: AnonymousUser' object has no attribute '_meta'. I am following the documentation from Django on how to log a user in, have tried that but I keep getting the error. https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.login view.py def signin(request): if request.method == 'GET': return render(request, 'auth/signin.html', { }) if request.method == 'POST': form = SigninForm(request.POST) if form.is_valid(): username = request.POST["username"] password = request.POST["password"] user = authenticate(request, username=username, password=password) if user is None: login(request, user) return HttpResponseRedirect('/') else: return HttpResponse('Invalid Credientials', status=401 ) else: return HttpResponse("Form is not valid", status=401) What I want is the user to signin but I keep getting the attribute error. -
Invalid block tag expected 'empty' or 'endfor'. Error trying to showing a ImageField
im tryinh to use the ImageField from pillow library. And i have a problem with that. When i try to show my image, i get the error: TemplateSyntaxError at /home Invalid block tag on line 62: 'articulo.nombre_imagen.url', expected 'empty' or 'endfor'. Did you forget to register or load this tag? this is my line 62: <a href="article/id/{{articulo.id}}"><img class="card-img-top" img src="{% articulo.nombre_imagen.url %}" alt=""></a> as you can use i am using the syntax correctly, well i supossed... this is from my models.py: def upload_location(instance, filename): return "static/img/" %(instance.id, filename) class Articulo(models.Model): nombre_imagen=models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field="height_field") width_field=models.IntegerField(default=0) height_field=models.IntegerField(default=0) Anyone can help? Thank you! -
How to write a business logic involving two models in Django Rest Framewor
I am confused and dont know how to write the business logic in django and django rest framework. Kindly help me out. Q. how to validate the student does not already exist in the registration table at the time of student creation. class Student(models.Model): name = models.CharField(max_length=300) sex = models.CharField(choices=SEX_CHOICES,max_length=255, null=True) Category = models.CharField(max_length=100, null=True) def __str__(self): return self.name RegisrationModel class Registration(models.Model): registration_no = models.CharField(max_length=255, unique=True) student = models.ForeignKey(Student, on_delete= models.CASCADE, related_name='registrations') def __str__(self): return self.registration_no -
From_email not functioning in Django
I am able to send emails using env variables etc. from a gmail account--however, it does not show the value of "from_email". I placed it as request.POST['from_email"] and it still shows the email I listed in my settings.py. I am trying to create a contact form from different email users to one recipient (which is in the settings.py) Also, since I put them in env variables--would I need to adjust the file when deploying it through AWS or should I be able to leave it as it is? Thank you! settings.py SECRET_KEY = os.environ.get('SECRET_KEY') EMAIL_HOST_USER=os.environ.get('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD=os.environ.get('EMAIL_HOST_PASSWORD') views.py def contact(request): message = request.POST.get('message', '') from_email = request.POST.get('from_email', '') send_mail('Contact Form', message, from_email, [settings.EMAIL_HOST_USER]) return render(request, 'first_app/contact.html') contact.html <form action="/contact" method="POST"> {% csrf_token %} <input type="email" name="from_email" placeholder="Your email"> <textarea name="message" placeholder="Message..."> </textarea> <input type="submit"/> </form> -
How to properly serve a Django site under a Sub URI in Apache?
I am trying to serve Mayan EDMS (a Django project) in a sub URI of another site. already checked and followed instructions from these posts: 1) https://gitlab.com/mayan-edms/mayan-edms/issues/350 2) How to host a Django project in a subpath? 3) https://docs.webfaction.com/software/django/config.html#mounting-a-django-application-on-a-subpath here is part of my apache config: ProxyPass /mayan http://127.0.0.1:8000 <Directory "/mayan"> Options FollowSymLinks Indexes SetHandler uwsgi-handler </Directory> Alias "/mayan-static" "/opt/mayan/mayan-edms/media/static/" <Location "/mayan-static"> SetHandler None Require all granted </Location> I added these in the Django settings file: USE_X_FORWARDED_HOST = True FORCE_SCRIPT_NAME = '/mayan' BASE_PATH = '/mayan' STATIC_URL = '/mayan-static/' MEDIA_URL = BASE_PATH + '/media/' I am expected that Mayan will be loaded in http://example.com/mayan, but it redirects to http://example.com/#/mayan ang give a 404 error. Did I miss something? or I do something wrong? -
How to create view to display inline models?
I created an admin form that creates model Catalog and has model Product inline to it. I created an index page that lists all of my catalog objects as a link and when I click that link I want to be able to view that catalog's products. I tried making the product page template identical to the catalog page template, but with catalog replaced with product wherever possible. Here is my models.py file class ProductInline(admin.TabularInline): model = Product extra = 1 class CatalogAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['catalog_text']}), ('Date information', {'fields': ['pub_date']}), ] list_display = ('catalog_text', 'pub_date', 'was_published_recently') list_filter = ['pub_date'] search_fields = ['catalog_text'] inlines = [ProductInline] Here is my catalog template {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}"> {% if latest_catalog_list %} Index <ul> {% for catalog in latest_catalog_list %} <li><a href="{% url 'scrappe:detail' catalog.id %}">{{ catalog.catalog_text }}</a></li> {% endfor %} </ul> {% else %} <p>You made a mistake</p> {% endif %} Here is my product template {% load static %} Detail <ul> {% for product in catalog %} <li><a href="{% url 'scrappe:detail' product.id %}">{{ product.product_text }}</a></li> {% endfor %} </ul> I thought this would display the products within the catalog, but only the … -
Custom fork of a package migrations for heroku
The package fork to which I am referring has no manage.py, so it's not like I can just do a manage.py makemigrations when I add fields to a model. Can anyone help? Here is the package: https://github.com/shanbay/django-vote And here is my fork: https://github.com/mike-johnson-jr/django-vote I added ip field to a model in the package (and some other minor edits). I need to make these migrations and migrate so my web app that uses this forked package can function properly. Will I need to add these migrations manually? More information: So, my package forked package works propertly locally because I was able to run makemigrations in my project locally. I can't do that in heroku (well I can, but they are not actually added and migrate cannot be used with them). I am trying to get my forked package running in production -- it is being hosted at heroku and the migrations do not make it over to the production server. What do I do? -
Django unable to connect postgres when dockerized
I keep trying to connect my django container to a postgres container and it just down not want to connect. My dockerfile for my Django project FROM python:3.6 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ RUN python catconstruct/manage.py migrate and my docker-compose: version: "3" services: db: image: postgres hostname: 'db' expose: - "5432" ports: - "5432:5432" kittenkube: build: . command: python catconstruct/manage.py runserver 0.0.0.0:80 restart: on-failure volumes: - .:/code environment: VIRTUAL_HOST: kk.example.org LETSENCRYPT_HOST: kk.example.org LETSENCRYPT_EMAIL: kk@example.org expose: - 80 depends_on: - db healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5432"] interval: 30s timeout: 10s retries: 5 networks: default: external: name: nginx-proxy Postgres seems to run just fine, as I can call docker-compose up db and then get into psql just fine. I added the hostname, expose, and ports parameters in an attempt to fix it, every other example online seems to just use the image parameter. Trying to troubleshoot I mostly call docker-compose up -d db (to ensure that the db is up and running) and then call docker-compose up --build -d kittenkube which then errors out on migrate with the error django.db.utils.OperationalError: could not translate host name "db" to … -
Django: formsModelMultipleChoiceField data not populating
I am making 2 very basic account types in my Django project: Instructor and Student. I want a list of the emails of Instructors who have signed up so Students can select their Instructor's email from the list when creating an account, thus linking the two accounts. forms.py class StudentSignUpForm(UserCreationForm): instructor_id = forms.ModelMultipleChoiceField(queryset=Instructor.objects.all()) class Meta(UserCreationForm): model = CustomUser fields = ('username', 'inGameName', 'instructor_id') help_texts = { 'username': 'Required', 'inGameName': 'Required; A name by which you can be identified', 'instructor_id': 'Optional; Provided by your professor', } @transaction.atomic def save(self): user = super().save(commit=False) user.is_student = True user.save() student = Student.objects.create(user=user) student.instructor_id = (self.cleaned_data.get('instructor_id')) return user class InstructorSignUpForm(UserCreationForm): email = forms.EmailField(label='Your Email', help_text='Required') class Meta(UserCreationForm.Meta): model = CustomUser fields = ('username', 'inGameName', 'email') help_texts = { 'username': 'Required', 'inGameName': 'Required; A name by which you can be identified', } @transaction.atomic def save(self): user = super().save(commit=False) user.is_instructor = True user.email = self.cleaned_data["email"] user.save() return user models.py class CustomUser(AbstractUser): is_student = models.BooleanField(default=False) is_instructor = models.BooleanField(default=False) username = models.CharField(max_length=40, primary_key=True, default='') inGameName = models.CharField("In-Game Name", max_length=40, default='') USERNAME_FIELD = 'username' class Instructor(models.Model): user = models.OneToOneField(CustomUser, default ='USER',on_delete=models.CASCADE) email = models.EmailField(max_length=254, unique=True, default='Email@Email.com') def __str__(self): return self.email class Student(models.Model): user = models.OneToOneField(CustomUser, default='USER', on_delete=models.CASCADE) instructor_id = models.ForeignKey(Instructor, … -
ListView has been overidden with get_context_data() and get_queryset() (django-filter) but won't display updated ListView
My user needs to dynamically filter to shorten the full list of data produced by default within the ListView. I've referred to the code examples for using django-filter from: Django how to get multiple context_object_name for multiple queryset from single view to single template https://simpleisbetterthancomplex.com/tutorial/2016/11/28/how-to-filter-querysets-dynamically.html https://kuttler.eu/en/post/using-django-tables2-filters-crispy-forms-together/ I've tried to customise def get_context_data() and def get_queryset() for ListView. At present the GET form correctly renders in the HTML template with fields for the user to filter the data with. However, upon submit (clicking the button), the list view does NOT filter, it continues to display the original, full list of data. Although, the list successfully updates using django-filter within a function based view and separate HTML file, I'd strongly prefer to remain in ListView as this page is linked to other views (Create, Delete and Update) and the ListView pagination functionality is needed. My initial guess is that ListView perhaps doesn't accept a user's GET request to dynamically filter as it ALWAYS automatically renders with all data? Thank you for any advice. filters.py - DataIntervalFilter class DataIntervalFilter(django_filters.FilterSet): class Meta: model = Data_Collection_Interval fields = ['staffrowid', 'datacollectstart',] views.py - ListView class DatesListView(StaffRequiredMixin, ListView): model = Data_Collection_Interval template_name = 'Administrator/manDates.html' context_object_name = 'intervals' … -
Send email using environment variables via Django for security
I can send emails using environment variables in my settings.py, however how do I input these variables in views.py? When put the actual email in str--it works; but for extra security, I written it as env. variable and gave me an error: SMTPRecipientsRefused. Also, how do I get it to show the sender's email. It shows in the console, but not when I receive the email. I am trying to get different users to send to one email recipient as contact form. settings.py: SECRET_KEY = os.environ.get('SECRET_KEY') EMAIL_HOST_USER=os.environ.get('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD=os.environ.get('EMAIL_HOST_PASSWORD') views.py: def contact(request): message = request.POST.get('message', '') from_email = request.POST.get('from_email', '') send_mail('Contact Form', message, from_email, ['EMAIL_HOST_USER']) return render(request, 'first_app/contact.html') contact.html: <form action="/contact" method="POST"> {% csrf_token %} <input type="email" name="from_email" placeholder="Your email"> <textarea name="message" placeholder="Message..."> </textarea> <input type="submit"/> </form> -
Custom User Model creates additional groups and permissions table
I'm using Django 2.2 I've created a Custom User model by inheriting from AbstractUser. Along with it, I also create a UserManager. # ./settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'rest_framework', 'core.apps.AuthConfig' ] AUTH_USER_MODEL = 'core.User' # ./core/models.py class User(AbstractUser): email = models.EmailField(_('email address'), unique=True) REQUIRED_FIELDS = ['first_name', 'last_name'] USERNAME_FIELD = 'email' objects = UserManager() # ./core/managers.py class UserManager(BaseUserManager): def create_user(self, email, password=None, **kwargs): if not email: raise ValueError('Email field is required') email = self.normalize_email(email) user = self.model(email=email, **kwargs) user.set_password(password) user.save() return user def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active', True) return self.create_user(email, password, **extra_fields) When I run: ./manage.py makemigrations ./manage.py migrate I get additional tables created in my database related groups and permissions. What's the purpose of this? Am I doing something wrong? I tried creating a group in Django admin and assigned a few permissions to it. Only the auth_group and auth_group_permissions table are being used. -
Managing migrations on a custom fork of a package
The package fork to which I am referring has no manage.py, so it's not like I can just do a manage.py makemigrations when I add fields to a model. Can anyone help? Here is the package: https://github.com/shanbay/django-vote And here is my fork: https://github.com/mike-johnson-jr/django-vote I added ip field to a model in the package (and some other minor edits). I need to make these migrations and migrate so my web app that uses this forked package can function properly. Will I need to add these migrations manually? Thanks in advance. -
How to process uploaded images in Django?
I've android application that uploads images to django server which hosted on 'pythonanywhere'. The android app works 100% it uploads images into the server and saves them correctly. my problem is I want to do some image processing on the received pictures on the server side I know how to do image processing but ''I The problem is I need to do an image processing code on the uploaded image right after the server catch the image and i don't know to how to do it in my code I've looked on djagno files on the server and I found models.py from django.db import models class MyImage(models.Model): model_pic = models.ImageField(upload_to = '', default = 'none/no-img.jpg') I guess the model_pic has the my uploaded photo -
How to pass a Form input as a variable to my class method
Short question : how can I pass the user's input from a form, to the parameter of my method class ? The user type a number, and this number is used in the method to multiply another value from the Class fields. I kept running into missing positional arguments error. I tried dozen of things, but cant figured out what I am doing wrong If I update the method to use a constant instead of a variable, everthing is rendering as I want on the template Model class Product(models.Model): sku = models.CharField(max_length=30) price = models.DecimalField(max_digits=5, decimal_places=2) def __str__(self): return self.sku def multi(self, n): np = self.price * n return np Views def index(request): list = Product.objects.all() if request.method == "POST": form = Input(request.POST or None) if form.is_valid(): value = request.POST.get('data') x = Product() x.multi(value) else: form = Input(request.POST or None) Form class Input(forms.Form): data = forms.DecimalField() -
How to get test coverage using django-nose and coverage
I am creating an API using DRF, I was able to setup Docker and was also able to integrate Travis CI. Everything was working fine Travis build was passing Until I tried to get Test Coverage that's when I got the error below: PermissionError: [Errno 13] Permission denied: '/app/.coverage' The command "docker-compose run app sh -c "python manage.py test"" exited with 1. Dockerfile file FROM python:3.7-alpine LABEL maintainer ="Daniel Otieno" ENV PYTHONUNBUFFERED 1 COPY ./requirements.txt /requirements.txt RUN pip install -r requirements.txt RUN mkdir /app WORKDIR /app COPY ./app /app RUN adduser -D user USER user docker-compose.yml file version: "3" services: app: build: context: . ports: - "8000:8000" volumes: - ./app:/app command: > sh -c "python manage.py runserver 0.0.0.0:8000" manage.py file import os import sys def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc is_testing = 'test' in sys.argv if is_testing: import coverage cov = coverage.coverage(source=['core'], omit=['*/tests/*']) cov.set_option('report:show_missing', True) cov.erase() cov.start() execute_from_command_line(sys.argv) if is_testing: cov.stop() cov.save() cov.report() if __name__ == '__main__': main() settings.py TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' NOSE_ARGS … -
Avoid validation of foreign key in django rest framework serializer
I write an API for the following models: class TemplateProjectGroup(models.Model): pass class TemplateProject(models.Model): name = models.CharField(max_length=255, unique=True) description = models.CharField(max_length=1024, blank=True) group = models.ForeignKey(TemplateProjectGroup, on_delete=models.CASCADE) project = models.ForeignKey(Project, on_delete=models.CASCADE) avatar_url = models.URLField(max_length=1024, blank=True) The logic is following: User can create an instance of TemplateProject with non existed group field. So if group is not existed, it should be created with a specific ID. So, I have this serializer: class TemplateProjectSerializer(serializers.ModelSerializer): def create(self, validated_data): template_project_group_id = validated_data.pop('group') project = validated_data.pop('project') group, _ = models.TemplateProjectGroup.objects.get_or_create(id=template_project_group_id) template_project = models.TemplateProject.objects.create(**validated_data, group_id=group.id, project_id=project.id) return template_project def update(self, instance, validated_data): template_project_group_id = validated_data.pop('group') group, _ = models.TemplateProjectGroup.objects.get_or_create(id=template_project_group_id) instance.save() instance.update(**validated_data, group=group) return instance class Meta: model = models.TemplateProject fields = ('name', 'description', 'group', 'project', 'avatar_url') and the view: class TemplateProjectsView(generics.ListCreateAPIView): pagination_class = None serializer_class = serializers.TemplateProjectSerializer def get_queryset(self): return models.TemplateProject.objects.all() It works well, when I try to retrieve list of objects, but I cannot create an object using this API, because I get following error: Invalid pk "1" - object does not exist. So, before creating an object, a validation is applied for all fields, and serializer cannot serialize this integer into an object because this object, which is referenced by foreign key, does not exist. I … -
Quiz App - Submit a question and go to the next one (Django Framework)
I have a question when submitting a question in my app and go to the next question. At the moment what I have is the following: from django.shortcuts import render, get_object_or_404, HttpResponse from . models import Certificacao, Certificado from questoes . models import Questao from multescolha . models import Alternativa from . forms import QuestaoForm from django.views.generic import ListView, FormView class HomeView(ListView): model = Certificacao template_name = 'certificacoes/index.html' def certificados(request, slug): certificacao = get_object_or_404(Certificacao, slug=slug) certificados = Certificado.objects.filter(certificacao__slug=slug) context = { 'certificacao': certificacao, 'certificados': certificados, } return render(request, 'certificacoes/certificados.html', context) class Perguntas(FormView): form_class = QuestaoForm template_name = 'certificacoes/pergunta.html' template_name_result = 'certificacoes/resultado.html' def get_form(self, *args, **kwargs): slug_certificado = self.kwargs['slug_certificado'] # url capturada via kwargs slug_certificacao = self.kwargs['slug_certificacao'] # url capturada via kwargs self.cache_questoes = Questao.objects.filter(situacao__certificado__slug=slug_certificado, situacao__certificado__certificacao__slug=slug_certificacao).values_list('id', flat=True) if len(self.cache_questoes) > 0: self.questao = Questao.objects.get_subclass(id=self.cache_questoes[0]) if self.form_class is None: form_class = self.get_form_class() else: form_class = self.form_class return form_class(**self.get_form_kwargs()) def get_form_kwargs(self): kwargs = super(Perguntas, self).get_form_kwargs() return dict(kwargs, questao=self.questao) def form_valid(self, form): hipotese = form.cleaned_data['respostas'] correto = self.questao.checar_correta(hipotese) if correto is True: return render(self.request, self.template_name_result, {'correto': correto, 'escolhida': self.questao.alternativa_escolhida(hipotese), 'fundamento': self.questao.alternativa_fundamento(hipotese), 'pergunta': self.questao}) else: return render(self.request, self.template_name_result, {'correto': correto, 'escolhida': self.questao.alternativa_escolhida(hipotese), 'fundamento': self.questao.alternativa_fundamento(hipotese), 'pergunta': self.questao}) def get_context_data(self, **kwargs): context = super(Perguntas, self).get_context_data(**kwargs) context['questao'] = … -
How can I use django-haystack search facets with custom attributes?
I have a Django-oscar shop and I successfully installed Solr 4.7.2 as search engine. It works great with the predefined attributes, e.g. upc, title, product_class... But filtering for additional attributes did not work. Thats my catalogue/models.py: class Product(AbstractProduct): video_url = models.URLField() co2 = models.IntegerField() is_public = models.BooleanField() test = models.TextField() In search_indexes.py, I tried to add something like: co2 = indexes.IntegerField(model_attr="co2", null=True, indexed=False) def prepare_co2(self, obj): return self.apps.get_model().objects.filter(co2="2") # return obj.co2 etc. here I tried a lot of code, but didnt work I also tried to copy the ready-made code for this function. Has anyone an idea, how to do that? When I filter for catalogue.products.title it works fine but not with cataolgue.products.co2 (which I have suplemented myself). -
How django "Timefield" can be timezone aware without date?
I want to make these fields timezone aware without date, default_start_time = models.TimeField(null=True, blank=True, default=None) default_end_time = models.TimeField(null=True, blank=True, default=None) so this value will show to the user based on activated timezone -
How to add a dynamic link {% url 'url_name' %} inside of a text field from Admin using Django-tinymce4-lite?
SO tinymce4 lie allows me to enter a link but when I enter {% url 'somelink' %} it doesnt get rendered properly. for example If my model is being render in the page of finance and I enter a link "2" the link would go to finance/2. I want to be able to use the django {% url %} functionality inside of tinymce4-lie. Any suggestion. I have tried to insert a link but that was not rendered correctly -
Using the __str__ method in Django to turn an object into a string - not working
I have the following code in models.py, note the function at the bottom that seeks to change the teacher_object in the admin panel to the username of the teacher instead. class Teachers(models.Model): email = models.CharField(max_length=50) school_pin = models.CharField(max_length=11) username = models.CharField(max_length=50) pass_field = models.CharField(db_column='pass', max_length=100) # Field renamed because it was a Python reserved word. fname = models.CharField(max_length=50, blank=True, null=True) lname = models.CharField(max_length=50, blank=True, null=True) oauth_provider = models.CharField(max_length=50, blank=True, null=True) oauth_uid = models.CharField(max_length=100, blank=True, null=True) verified = models.IntegerField(blank=True, null=True) verificationcode = models.CharField(db_column='verificationCode', max_length=100, blank=True, null=True) # Field name made lowercase. school_name = models.CharField(max_length=255, blank=True, null=True) designation = models.CharField(max_length=255, blank=True, null=True) date = models.DateField(blank=True, null=True) membershipid = models.IntegerField(blank=True, null=True) def __str__(self): return self.username The admin panel still shows the teachers listed as Teachers object (1275) (and so on). I have tried the following: 1. Running the makemigrations and migrate commands 2. Logging in and out of the admin panel 3. Refreshing and closing down CMD - restarting None of the above has worked. There are no errors on running the server. Python version: 3.7 Latest Django installation -
how to fix this 404 error in django urlconfig patterns
I'm creating a basic app in my django project.i mapped the views to url.while running this project it is showing 404 page not found. in urls.py from django.urls import path from . import views urlpatterns=[ path('myapp/',views.index,name="index"), ] in views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse("hello world"); I expect the output to be like hello world -
builtins.AttributeError: 'int' object has no attribute 'splitlines'
I followed the example listed on https://medium.com/@ali_oguzhan/how-to-use-scrapy-with-django-application-c16fabd0e62e. Why am I getting this error after curl? Is that a problem with my Python 3.7 lib? I am using django 2.0 and Scrapy 1.5.1. <html><head><title>web.Server Traceback (most recent call last)</title></head><body><b>web.Server Traceback (m ost recent call last):</b> <div> <style type="text/css"> div.error { color: red; font-family: Verdana, Arial, helvetica, sans-serif; font-weight: bold; } div { font-family: Verdana, Arial, helvetica, sans-serif; } div.stackTrace { } div.frame { padding: 1em; background: white; border-bottom: thin black dashed; } div.frame:first-child { padding: 1em; background: white; border-top: thin black dashed; border-bottom: thin black dashed; } div.location { } span.function { font-weight: bold; font-family: "Courier New", courier, monospace; } div.snippet { margin-bottom: 0.5em; margin-left: 1em; background: #FFFFDD; } div.snippetHighlightLine { color: red; } span.code { font-family: "Courier New", courier, monospace; } </style> <div class="error"> <span>builtins.AttributeError</span>: <span>'int' object has no attribute 'splitlines'</span> -
How does implementing any djago apps into my own project works?
help needed for general advice with the example on how to implement django apps. I am trying to implement django app called django-simple-polls. After installing the app with... pip install ... ...adding the app in INSTALLED APPS ...the server still runs... ...migrations runs with no problem... ...being able to create basic poll from the admin... questions starts here as I do not know how can I see the poll on the server: 1) urlpatterns = [ ... url(r'^poll/', include('poll.urls')), ] I am guessing polls app is installed somewhere within django so I do not have to create any additional folder/file in my project. Do I need to import a library to use the include() function? It also mean I need to run polls only in that certain url? That means 'poll.urls' already exist? 2) Add this tags in your template file to show the poll: {% load poll_tags %} ... {% poll %}` Again my guess is just to create any template folder and put as base the code above. What does "..." mean?. Where do I put the above code? How do I call that HTML file? Is that pretty much the only way of building apps into a …