Re: Input Widget with multiple input_type attr

2017-10-20 Thread mohammad k
forms.CharField(widget=forms.HiddenField) On Oct 21, 2017 12:45 AM, "gugsrs" wrote: Hello, I am having some problems with django 1.11 widgets, I was using django-widget-tweaks to help rendering form fields, but now when I set a type="hidden" attribute to an Input Field, django creates the widge

Re: Insert data into multiple models

2017-10-23 Thread mohammad k
you can use model signals On Mon, Oct 23, 2017 at 4:15 PM, Mukul Mantosh wrote: > I have two models (User and Employee). I want to create a new user and > make a reference between employee and user. > > > *User Table* > 1. Name > 2. E-Mail > 3. Date of Birth > 4. Contact Number > > > *Employee

Re: Insert data into multiple models

2017-10-23 Thread mohammad k
https://docs.djangoproject.com/en/1.11/topics/signals/ On Mon, Oct 23, 2017 at 8:22 PM, mohammad k wrote: > you can use model signals > > > On Mon, Oct 23, 2017 at 4:15 PM, Mukul Mantosh > wrote: > >> I have two models (User and Employee). I want to create a new user

Re: Input Widget with multiple input_type attr

2017-10-24 Thread mohammad k
forms.TextInput(attrs={'type': 'hidden'}) On Tue, Oct 24, 2017 at 7:08 PM, gugsrs wrote: > But isn't there any other way to change that attribute from my template > for example? > > Thank you for the reply. > > On Saturday, October 21, 2017 at 4:19:21 AM UTC-2, k2527806 wrote: >> >> forms.CharFi

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
try that in your views form = Dog_Form(request.POST) if form.is_valid(): form_save = form.save(commit=False) form_save.user = request.user # user is logged in form.save() On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang wrote: > Let's say I have a model called 'Dogs'. Users can create

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
for question 2 : def get_queryset(self): # the user want to edit this post must be owner this post post_qs = super(UpdatePost, self).get_queryset() return post_qs.filter(user=self.request.user) On Tue, Oct 24, 2017 at 8:04 PM, mohammad k wrote: > try that in your vi

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
class Upload(FormView): http_method_names = ['get', 'post'] template_name = 'public/upload.html' success_url = reverse_lazy('upload') form_class = UploadForms def get(self, request, *args, **kwargs): form = self.form_class(user=request.user) return render(reques

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
use FormView https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-editing/#formview On Wed, Oct 25, 2017 at 1:21 PM, mohammad k wrote: > class Upload(FormView): > http_method_names = ['get', 'post'] > template_name = 'public/upload.html

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
that your code : class CreatePost(CreateView): model = Post def form_valid(self, form): form.instance.user = self.request.user return super(CreatePost, self).form_valid(form) On Wed, Oct 25, 2017 at 1:22 PM, mohammad k wrote: > use FormView > &

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
code : >> class CreatePost(CreateView): >> model = Post >> >> def form_valid(self, form): >> form.instance.user = self.request.user >> return super(CreatePost, self).form_valid(form) >> >> On Wed, Oct 25, 2017 at 1:22 PM, mohammad k wro

Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
use this code for ManytoMany fields in django admin : filter_horizontal = ('groups', 'user_permissions',) On Fri, Nov 3, 2017 at 1:45 PM, Paul wrote: > I have a Product model, an Image Model and a Category Model. > > A Product can have multiple Images(Foreign Key) and a Product can be in > mult

Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
) list_display = [ 'username', 'email', 'last_name', 'user_reg', # refer to Registration model 'is_staff', ] list_filter = ('date_joined', 'is_staff', 'is_superuser'

Re: django 1.11 run error

2017-11-22 Thread mohammad k
If you use virtualenv, first of all activate the virtualenv On Nov 22, 2017 8:12 PM, "ngn zone" wrote: Hello all, I am new to Django. I am trying to run a project and when I run "python manage.py makemigrations " I get the following error message. What am I doing wrong? python manage.py mak

Re: How do I make my form send a POST request to a specified view?

2017-11-23 Thread mohammad k
login_register.html : {% csrf_token %} {{ registration_form.as_p }} Register On Nov 24, 2017 1:42 AM, "Tom Tanner" wrote: > My page has a registration form at `"/login_register/"`. I want the form > to send a POST request to `"/register/"`. Here's my code so far. > > `urls.py`: > url("^

Re: How do I limit my login form to just email and password?

2017-11-26 Thread mohammad k
forms.py : class LoginUserForm(forms.Form): email = forms.CharField( widget=forms.EmailInput(attrs={'autofocus': True, 'placeholder': 'Email'}), required=True, label='Email :', max_length=255 ) password = forms.CharField( widget=forms.PasswordInp

Re: How to configure NGINX to run Django app in a subpath?

2017-11-26 Thread mohammad k
https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html On Sun, Nov 26, 2017 at 11:26 PM, Luca Moiana wrote: > Hi, > > Sorry for the slight OT but after days of search I have no clue. > > > Following this DigitalOcean tutorial >

Re: Django Translation

2017-08-30 Thread mohammad k
read django-translatin-manager docs On Wed, Aug 30, 2017 at 11:50 AM, wrote: > Hi, > > I have a django application developed with static files from AngularJS. I > need to translate the site to French and give option to users to select > language. I have used django-translatin-manager for loading

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
and in url.py beside settings.py use code like that : url('^polls/',include('polls.urls')), On Wed, Aug 30, 2017 at 4:29 PM, mohammad k wrote: > from django.conf.urls import url > from . import views > > app_name = 'polls' > urlpatterns = [ >

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
like that : app_name = 'polls' in polls folder and in url.py On Wed, Aug 30, 2017 at 4:26 PM, mohammad k wrote: > you have Different app in your project yes ? > you have to use app_name in url.py in each app > > On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner > wrote:

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
you have Different app in your project yes ? you have to use app_name in url.py in each app On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner wrote: > This has bamboozled me some. And the best thing I've found on-line doesn't > seem to apply: > > https://stackoverflow.com/questions/26944908/dja

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
i can't do that sorry man Tell me more clearly, so I may help you better On Wed, Aug 30, 2017 at 5:16 PM, Daniel Roseman wrote: > On Wednesday, 30 August 2017 12:42:01 UTC+1, Bernd Wechner wrote: >> >> This has bamboozled me some. And the best thing I've found on-line >> doesn't seem to apply: >

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
)/results/$', views.ResultView.as_view(), name='results'), url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'), ] you have to create a url.py for each app in them folder On Wed, Aug 30, 2017 at 4:27 PM, mohammad k wrote: > like that : > app_name = '

Re: Doubts about static files

2017-08-30 Thread mohammad k
move the static folder beside the settings.py On Wed, Aug 30, 2017 at 6:32 PM, mohammad k wrote: > STATIC_URL = '/static/' > STATICFILES_DIRS = ( > os.path.join(BASE_DIR, 'firstdjango', 'static'), > ) > STATIC_ROOT = '/Users/mk/Desktop/api

Re: Doubts about static files

2017-08-30 Thread mohammad k
STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'firstdjango', 'static'), ) STATIC_ROOT = '/Users/mk/Desktop/api/New folder/' : When you run collectstatic files moves files from static files from static folder to desktop. add this settings to the settings.py On Wed, Aug 30,

Re: Bizarre URL behaviour after deploying

2017-09-01 Thread mohammad k
when you use the url tage in templates you have to used like that {% url 'polls:edit' parameters %}: polls is the app or controller and the edit is view or method On Thu, Aug 31, 2017 at 4:46 PM, Melvyn Sopacua wrote: > You may have a reverse proxy on port 80 that incorrectly rewrites > /(.*) to