DB design

Hi.I am into django for hardly 6 months.And hence I am not that great in designing Databases.So can any one provide a sample models for creating an e commerce website?(including basic features like user cart etc.)

Guest Aug. 28, 2016, 1:33 p.m. 0 Answer 


Hi, i wanted to ask about djangocms. How can I add new language for translation this site

tolqinbek_isoqov@mail.ru July 20, 2016, 11:59 p.m. 0 Answer 

How do I create a folder for a model when I submit the form in the admin page?

Hello. I'm new to Django and I'm having trouble figuring out how to do it.


My model is like this:

class Clinica(models.Model):
    def __str__(self):
        return self.nome

    nome        = models.CharField(max_length=20)
    site        = models.URLField(blank=True,null=True)
    folder      = models.FilePathField(blank=True,null=True)
    data_inc    = models.DateTimeField('Data Publicada')
    data_lim    = models.DateField('Vencimento')


How can I create that folder?

Guest July 19, 2016, 4:20 p.m. 0 Answer 

logging-in into a webpage using our LDAP credentials in django using django_auth_ldap module

I am using django_auth_ldap module to authenticate LDAP users who are logging into my web page.

Edited my settings.py file as per the document https://pythonhosted.org/django-auth-ldap/example.html

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType

# Baseline configuration.
AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"

AUTH_LDAP_BIND_DN = "cn=django-agent,dc=example,dc=com"
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",
    ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
# or perhaps:
# AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com"

# Set up the basic group parameters.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=django,ou=groups,dc=example,dc=com",
    ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn")

# Simple group restrictions
AUTH_LDAP_REQUIRE_GROUP = "cn=enabled,ou=django,ou=groups,dc=example,dc=com"
AUTH_LDAP_DENY_GROUP = "cn=disabled,ou=django,ou=groups,dc=example,dc=com"

# Populate the Django user from the LDAP directory.
    "first_name": "givenName",
    "last_name": "sn",
    "email": "mail"

    "employee_number": "employeeNumber"

    "is_active": "cn=active,ou=django,ou=groups,dc=example,dc=com",
    "is_staff": "cn=staff,ou=django,ou=groups,dc=example,dc=com",
    "is_superuser": "cn=superuser,ou=django,ou=groups,dc=example,dc=com"

    "is_awesome": "cn=awesome,ou=django,ou=groups,dc=example,dc=com",

# This is the default, but I like to be explicit.

# Use LDAP group membership to calculate group permissions.

# Cache group memberships for an hour to minimize LDAP traffic

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.

I want clarification on few things. i,e to get a login page and to authenticate the logged in LDAP user:

  1. login url, login view, html template for login page should be created explicitly" ??
  2. If they are autogenerated, how can we get the username and password entered by user and search for the same using AUTH_LDAP_USER_SEARCH.

Guest May 18, 2016, 5:39 a.m. 0 Answer 

Problem with running Django admin panel

I am new in Django. After running server when I enter the server address then it works fine. But when I put(/admin) after the url then Django ask me to enter username and password. The funny thing is when I enter anything in username and password box and press login then it redirect me to the desired page. How can I get rid of it?


Guest May 3, 2016, 2:04 p.m. 1 Answer 

Django for Plotting


Is it possible to Plot data (.csv) into a hosted website designed using Django ?

data will be sent from a computer ( or mini computer like Raspberry ) to server where it will be plotted into STREAMING GRAPHS, Users can have access to the live streaming or archive

Is that possible with only Django/python?


Thank you.

mehdikun1@gmail.com April 1, 2016, 5:42 p.m. 2 Answer 

Showing most visited article in my blog



In the blog there will be many article. So i have a question How to show  most visited article in a window in my blog font page? please feedback with details so that i can add this solution in my blog.


thanks a lot.


ranafge@gamil.com Feb. 16, 2016, 12:14 p.m. 1 Answer 

Showing most visited article


In the blog there will be many article. So i have a question How to show  most visited article in a window in my blog font page? please feedback with details so that i can add this solution in my blog.


thanks a lot.


Guest Feb. 16, 2016, 12:11 p.m. 0 Answer 

cmsplugin_contact own form template problem

Hi there,

I am trying to create my own formular by extending yours cmsplugin_contact plugin and I just have one problem. My template doesn't notice any of multiple variables in my models.py. I don't know why.


My forms.py:

class forms_lead(ContactForm):
    lead_companycity = forms.CharField(required=True, label=_('City'))
    lead_contactemail = forms.EmailField(required=True, label=_('E-mail'))
    template = "leadform.html"

My models.py:

class models_lead(BaseContact):
    lead_title = models.CharField(_('Title'), max_length=50, default="My form",)
    def __str__(self):
        return self.lead_title

My cms_plugins.py:

class LeadFormPlugin(ContactPlugin):
    module = _('My forms')
    name = _("Lead Form")
    model = models_lead
    contact_form = forms_lead
    render_template = "leadform.html"
    email_template = "leadform_email.txt"
    fieldsets = (
        (None, {
            'fields': ('form_name', 'form_layout', 'site_email', 'lead_title',),
            'fields': ('thanks', 'redirect_url' ),
         } ),
        (_('Spam Protection'), {
            'fields': ('spam_protection_method', 'akismet_api_key',
                       'recaptcha_public_key', 'recaptcha_private_key', 'recaptcha_theme')

and my template:

{% load cms_tags i18n %}
<div class="col-lg-8">
    {% if form %}
        <form action="." method="post">
        {% csrf_token %}
        <!-- Lead form -->
            <!-- Title -->
              <h2>{{ models_lead.lead_title }}</h2>THIS TWO HEADERS ARE NOT WORKING...
              <h2>{{ instance.lead_title }}</h2>  THIS TWO HEADERS ARE NOT WORKING...
              <div class="col-lg-12">  This is working without problem...
                      <div class="col-lg-6">
                          <p>{{ form.lead_contactname.label_tag }}</p>
                          {{ form.lead_contactname }}
                      <div class="col-lg-6">
                          <p>{{ form.lead_contactdepartment.label_tag }}</p>
                          {{ form.lead_contactdepartment }}

I tried everything what came to my mind... I just don't know how to get variables from models to template... Any advice?

Guest Feb. 4, 2016, 7:42 a.m. 0 Answer 

call model from within self model in django

I want to access to self model from within same model 

class Category(models.Model):
    title = models.CharField(...)

    def __unicode__(self):
        p1 = Category.objects.get(title='X')
        p2 = Category.objects.get(title='Y')
        p3 = Category.objects.get(title='Z')
        #OR p2 = self.objects.get(title=self.title)
        #OR p2 = Category.__class__.objects.get(title=self.title)

        return "{}-{}-{}".format(p1,p2,p3)

Guest Jan. 17, 2016, 1:48 a.m. 0 Answer 

Django Project not serve data on Windows 10

up vote0down votefavorite

I have project in Django(1,8,0,'final',0). And we did not get anything on Browser in windows 10 . In Ubuntu it working fine. So to check more
I create a very new Project in Django(1,8,0,'final',0) by using command django-admin startproject mysite. In my localhost(Ubuntu) it serve template

It worked! Congratulations on your first Django-powered page.

But in windows it did not render anything . Anything at all in Chrome browser .In checking network in chrome we get 200 status code . I also check on other browsers like firefox and IE in Windows but same problem.

In windows 10(Laptop) other project run on java and node working fine. Any suggestion what is the problem is?

abhaygarg12493@gmail.com Jan. 13, 2016, 5:48 a.m. 0 Answer 

Saving data in a model from two different templates


i have two different templates( one redirects to another). I want to take in values from both of them and then save in one model, is it possible?


i did similar ajax calls like


        $.ajax({type: 'POST',
                url: '/savedetails',                            // some data url
                data: {name:profile.getName(),email:profile.getEmail(), time:date},       // some params  
                success: function (response) {                  // callback
                    if (response.result === 'OK'){
                location.href = "/select";



on both the html templates, but unable to get the clear picture of how to do it, plus when encountering my second page i get an error broken pipe.


soumi1naughty@gmail.com Sept. 4, 2015, 4:21 a.m. 1 Answer 

How to save data with Django ckeditor in database using normal forms?

I am working with custom form application and I want to integrate ckeditor into it. It works perfectly fine in Django Admin forms but does not work in normal forms.



from django.db import models
from django.contrib.auth.models import User
from ckeditor.fields import RichTextField

class Post(models.Model):
    text = RichTextField()

    updated = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ['created']

    def __unicode__(self):
         return self.text



from django.conf.urls import patterns, url

urlpatterns = patterns(
    url(r'^$', 'home'),
    url(r'^create_post/$', 'create_post'),
    url(r'^delete_post/$', 'delete_post'),



def home(req):

    tmpl_vars = {
        'all_posts': Post.objects.reverse(),
        'form': PostForm()
    return render(req, 'editor/index.html', tmpl_vars)

def create_post(request):
    if request.method == 'POST':
        post_text = request.POST.get('the_post')
        response_data = {}
        post = Post(text=post_text)
        post_form = Post()

        response_data['result'] = 'Create post successful!'
        response_data['postpk'] = post.pk
        response_data['text'] = post.text
        response_data['created'] = post.created.strftime('%B %d, %Y %I:%M %p')

        return HttpResponse(

        return HttpResponse(
            json.dumps({"nothing to see": "this isn't happening"}),


class PostForm(forms.ModelForm):
    text = forms.CharField(widget = CKEditorWidget())
    class Meta:
        model = Post



<form method="POST" id="post-form">
        {% csrf_token %}
        <div id="the_post">
            {{ form.media }}
            {{ form.as_p }}
        <div id="results"></div>
        <button type="submit">{% trans 'Submit' %}</button>


In django admin data is saving with ckeditor, while using ckeditor in custom form data is not saving in database. Please help.

Guest March 8, 2015, 12:35 p.m. 2 Answer 
Load More Questions

Codility : Nesting

Determine whether given string of parentheses is properly nested.

email@djangotutsme.com April 21, 2016, 9:03 a.m.

Codility : Brackets

Determine whether a given string of parentheses is properly nested.

email@djangotutsme.com April 18, 2016, 2:31 a.m.

Bubble sort in Python

In this article you can see how to use Bubble sort in python

email@djangotutsme.com April 16, 2016, 9:36 a.m.

Codility : Triangle

Determine whether a triangle can be built from a given set of edges.

email@djangotutsme.com April 6, 2016, 8:23 a.m.

Codility : Distinct

Compute number of distinct values in an array.

email@djangotutsme.com April 6, 2016, 7:53 a.m.

Codility : MinAvgTwoSlice

Find the minimal average of any slice containing at least two elements.

email@djangotutsme.com April 5, 2016, 2:12 p.m.

Codility : PassingCars

Count the number of passing cars on the road.

email@djangotutsme.com March 29, 2016, 3:49 a.m.

How to add custom django manager

In this article I'll show you how to create custom django manager. A Manager is the interface through which database query operations are provided to Django models. At least one Manager exists for every model in a Django application.

email@djangotutsme.com Jan. 5, 2015, 8:42 a.m.